Skip to main content

A flake8 extension that checks for type annotations complexity

Project description

flake8-annotations-complexity

Build Status Maintainability Test Coverage PyPI - Python Version

An extension for flake8 to report on too complex type annotations.

Complex type annotations often means bad annotations usage, wrong code decomposition or improper data structure choice. They are also hard to read and make code look java-like.

Annotation complexity is maximum annotation nesting level. So List[int] complexity is 2 and Tuple[List[Optional[str]], int] is 4.

Default max annotation complexity is 3 and can be configured via --max-annotations-complexity option.

Installation

pip install flake8-annotations-complexity

Example

Sample file:

# test.py

def foo() -> List[int]:
    return [1]

Usage:

$ flake8 --max-annotations-complexity=1 test.py
test.py:4:14: TAE002 too complex annotation (2 > 1)

Contributing

We would love you to contribute to our project. It's simple:

  1. Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
  2. Create a pull request. Make sure all checks are green.
  3. Fix review comments if any.
  4. Be awesome.

Here are useful tips:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_annotations_complexity-0.0.8.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file flake8_annotations_complexity-0.0.8.tar.gz.

File metadata

File hashes

Hashes for flake8_annotations_complexity-0.0.8.tar.gz
Algorithm Hash digest
SHA256 8914e76e31672c4063c928b0a250db6b935a16d1799de10457958a71d11bb665
MD5 c2267c45daeb1e451ebd8c5f3b03f73a
BLAKE2b-256 d02295d82ddf351f3b0fe84fad532798d36797be0fb29d593b403740fe30dacc

See more details on using hashes here.

File details

Details for the file flake8_annotations_complexity-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_annotations_complexity-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 44e299dac0ab64f3af4b478fac7feb635c113a606036de8b39dadab3531da7ed
MD5 20f7d38513977a4b8573008ae993b2e4
BLAKE2b-256 860f5fc1850490364aa4f16d1fce3c5727b09c579332ba90d3fbf4e017196e0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page