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)

Tested on Python 3.6, 3.7, 3.8, 3.9 and flake8 3.7.9.

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.6.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: flake8_annotations_complexity-0.0.6.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for flake8_annotations_complexity-0.0.6.tar.gz
Algorithm Hash digest
SHA256 32dfc8f42df3b16fb4fbc66a287433e176ae1bd39894d9aec898cfc70aef25cb
MD5 f935850063d73477b5561a5342aa1047
BLAKE2b-256 72d84330d14fb22532f4862199407e3efc65419af9c5ecc108eb28dc713a5154

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flake8_annotations_complexity-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for flake8_annotations_complexity-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 078a84e8269ef82c4c9de5198638e9a91a2089307d4e559666464a87b528ea69
MD5 14d3a1dd8cd416993681462f731e51b9
BLAKE2b-256 cdfcc9ae6767d9bbab0a6e1a37dcd8b64352de8c5011651d0e0cdb9ca3bcd6c2

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