Skip to main content

A flake8 extension that checks for type annotations complexity

Project description


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.


pip install flake8-annotations-complexity


Sample file:


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


$ flake8 --max-annotations-complexity=1 TAE002 too complex annotation (2 > 1)

Tested on Python 3.5.0 and flake8 3.7.4.


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:

Download files

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

Files for flake8-annotations-complexity, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size flake8_annotations_complexity-0.0.5.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page