skillfed

flake8-annotations-complexity

A flake8 extension that checks for type annotations complexity

flake8-annotations-complexity v0.2.0 332.8K downloads/30d#7,505 on PyPI50
Permissive license MIT Active released

What it is and what it does

flake8-annotations-complexity is a flake8 extension that measures and enforces limits on type annotation complexity. It defines complexity as the maximum nesting level of type brackets—for example, `List[int]` has complexity 2, while `Tuple[List[Optional[str]], int]` has complexity 4. The plugin checks annotations on function arguments (positional, keyword-only, *args, **kwargs), return types (including async functions), and annotated variable assignments.

The plugin provides two checks: TAE002 flags annotations exceeding a nesting-depth threshold (default 3), and TAE003 flags annotations with too many elements (default 7). Both thresholds are configurable via flake8 command-line options. It runs on Python 3.10 through 3.14 and integrates directly into your existing flake8 workflow, making it easy to catch overly complex type hints during development or CI.

Use it for:

  • Enforce a team style guide that discourages deeply nested generics like `Dict[str, List[Tuple[int, Optional[str]]]]` in code review.
  • Catch annotation mistakes early—complex annotations often signal bad decomposition or wrong data structure choices.
  • Improve code readability by flagging annotations that are hard to parse at a glance.
  • Prevent Java-like verbosity in Python type hints during refactoring or new feature development.
  • Integrate into CI/CD pipelines to maintain consistent annotation standards across a project.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A flake8 plugin that flags type annotations exceeding configurable complexity thresholds, measuring nesting depth and element count to encourage simpler, more readable type hints.

Yes. The plugin is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and adds minimal install friction (only flake8 as a dependency). It solves a real code-quality problem—catching overly complex type annotations—and integrates seamlessly into existing flake8 workflows. Install it if your team values readable, maintainable type hints.

Install

flake8-annotations-complexity on PyPI

pip

pip install flake8-annotations-complexity

uv

uv add flake8-annotations-complexity

poetry

poetry add flake8-annotations-complexity

Installing flake8-annotations-complexity

Before you install

Low friction: pure Python wheel with only flake8 as a runtime dependency. Actively maintained as of 2026-08-14 with no known vulnerabilities.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open and closed projects.

Quickstart

pip install flake8-annotations-complexity

# In your flake8 config or command line:
flake8 --max-annotations-complexity=3 --max-annotations-len=7 mycode.py

# Reports TAE002 (nesting too deep) and TAE003 (too many elements)

Requires Python 3.10 or later; flake8 must be installed and configured.

Verify before relying

  • Whether the plugin integrates seamlessly with existing flake8 configurations and CI/CD pipelines.
  • Performance impact on large codebases with many type annotations.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — flake8
Maintenance actively maintained — 0 days since the last release
Last repo commit
First released
Downloads 332,768/month — #7,505 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: flake8_annotations_complexity-0.2.0-py3-none-any.whl

Keywords: annotations, flake8

Environment :: ConsoleFramework :: Flake8Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: DocumentationTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

flake8 type annotation complexitycheck annotation nesting depthenforce simpler type hintsannotation length linterreduce annotation complexityflake8 annotation checkertype hint quality tool
lintingtype-hintscode-quality

More Python Modules packages

idna

Converts domain names between Unicode and…

permissive · top 100 on PyPI

setuptools

Setuptools is a Python build backend and…

permissive · top 100 on PyPI

PyYAML

PyYAML parses and emits YAML 1.1 data format,…

permissive · top 100 on PyPI

pydantic

Pydantic validates Python data structures…

permissive · top 100 on PyPI

annotated-types

Provides reusable metadata objects for use with…

permissive · top 100 on PyPI

typing-inspection

Provides runtime tools to inspect and…

permissive · top 100 on PyPI

flake8-class-attributes-order

A flake8 extension that enforces a configurable…

permissive · top 15,000 on PyPI

flake8-expression-complexity

A flake8 extension that detects overly complex…

permissive · top 15,000 on PyPI

flake8-functions

A flake8 extension that enforces function-level…

permissive · top 15,000 on PyPI

flake8-cognitive-complexity

A flake8 extension that checks Python code for…

permissive · top 15,000 on PyPI

cognitive-complexity

Calculates cognitive complexity scores for…

permissive · top 15,000 on PyPI

code-annotations

Parses and summarizes code annotations…

permissive · top 15,000 on PyPI

flake8-type-checking

A flake8 plugin that identifies which imports…

permissive · top 15,000 on PyPI

flake8-annotations

A Flake8 plugin that enforces PEP 3107-style…

permissive · top 15,000 on PyPI

mccabe

Measures cyclomatic complexity of Python…

permissive · top 1,000 on PyPI

flake8-variables-names

A flake8 extension that detects poorly named…

permissive · top 15,000 on PyPI