A Flake8 plugin that checks for missing PEP 3107-style type annotations in Python functions and methods.
flake8-annotations is a Flake8 plugin that statically analyzes Python code to detect missing type annotations in function and method signatures. It enforces the use of PEP 3107-style annotations, helping teams adopt consistent typing practices without performing full type checking. The tool focuses on annotation presence, leaving deeper type validation to dedicated type checkers like mypy.
Python developers and teams who want to enforce type annotation consistency in their codebases, particularly those using Flake8 for linting and aiming to improve code documentation and maintainability.
Developers choose flake8-annotations for its focused, configurable approach to annotation enforcement, seamless integration with Flake8, and ability to catch missing annotations early in the development cycle without the overhead of a full type checker.
Flake8 Type Annotation Checking
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Specifically targets missing PEP 3107-style function annotations, helping teams adopt consistent typing practices without the overhead of full type checking, as stated in the README's philosophy.
Offers flags like --dispatch-decorators and --overload-decorators to suppress warnings for generic functions, with clear examples for singledispatch and overload decorators in the README.
Includes warnings for missing annotations on self and cls parameters in methods, referencing PEP 484 and PEP 563 for guidance on annotating instance and class methods.
Installs as a Flake8 plugin and runs automatically, with verification shown in the README's installation example using flake8 --version.
Only checks annotation presence, not type correctness; the README explicitly states it won't replace mypy, leaving deeper type checking to dedicated tools.
Does not support PEP 526 variable annotations, which is a gap for modern Python codebases using variable type hints, as mentioned in the README's limitations.
Flags like --dispatch-decorators have limitations, such as no support for deeper imports (e.g., a.b.singledispatch), and dynamic typing support is restricted to specific patterns, adding setup complexity.