flake8-annotations-complexity
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.
The plugin checks annotations of every argument kind (positional-only, regular,
*args, keyword-only and **kwargs), return types of both regular and async
functions, and annotated assignments.
Checks
| Code | Description | Option | Default |
|---|---|---|---|
TAE002 |
Annotation is too complex (nesting level) | --max-annotations-complexity |
3 |
TAE003 |
Annotation is too long (number of elements) | --max-annotations-len |
7 |
Requirements
Python 3.10 – 3.14.
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:
- Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
- Create a pull request. Make sure all checks are green.
- Fix review comments if any.
- Be awesome.
Here are useful tips:
- The project uses uv. Run
make install(oruv sync) to create the environment. - Install the git hooks once with
uv run pre-commit install. - You can run all checks and tests with
make check. Please do it before CI does. - We use BestDoctor python styleguide.
- We respect Django CoC. Make soft, not bullshit.
Metadata
Release files for flake8-annotations-complexity 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8_annotations_complexity-0.2.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_annotations_complexity-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / flake8_annotations_complexity-0.2.0.tar.gz
| Download URL | flake8_annotations_complexity-0.2.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06d3b20aa6048642860b54dfcb74ec786e97a4f65d7548d9ab3f2b77ab60e1ec
|
|
BLAKE2b-256 checksum How to use checksums |
ac00105bd4fcc95e0b73873bf6cc7eb91f19ba8630953c116b6cababf3fe7543
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logRelease files / flake8_annotations_complexity-0.2.0-py3-none-any.whl
| Download URL | flake8_annotations_complexity-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3b86dd5dbbf5eeb5b2ff5c0a68c7dddbcfc0766e057793734b5ccf2a75cf43f
|
|
BLAKE2b-256 checksum How to use checksums |
fe298160194a6275c1847ed0f426c79ac01e348d27930db12d6626af15e95905
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency log