Skip to main content

A flake8 extension that checks for type annotations complexity

Project description

flake8-annotations-complexity

Build Status Maintainability Test Coverage PyPI version 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.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for flake8_annotations_complexity-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98b86ef87de5331d2b61f3cf472dcf6b8ff1a5ddde46f78bc894b464f06e1414
MD5 9c945c6e1017e4ef8c3d8c0919210e38
BLAKE2b-256 fa68ab6f136df474fbbddad1bff3965b9857a89327d819a385c815549a884cd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_annotations_complexity-0.1.0.tar.gz:

Publisher: publish.yml on best-doctor/flake8-annotations-complexity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for flake8_annotations_complexity-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 102d75f5ba0c667cde9c563062f4e7c616ca84bf5bfdc9c1f960a2655133ce35
MD5 ff723103896551e2c437563e6fd8a550
BLAKE2b-256 c28cdcd25a2c5b727851c28e1875a04dadd8e22b31564502eea63d5977cd31a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_annotations_complexity-0.1.0-py3-none-any.whl:

Publisher: publish.yml on best-doctor/flake8-annotations-complexity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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