Flake8 Annotations

3.2.0 · active · verified Sun Apr 12

Flake8 Annotations is a plugin for Flake8 that enforces the presence and style of PEP 3107-style function annotations in Python code. It helps maintain consistent typing practices by flagging missing or incorrect type annotations. The current version is 3.2.0, and the project is actively maintained with regular updates addressing Python and Flake8 compatibility.

Warnings

Install

Imports

Quickstart

Install flake8 and flake8-annotations. Create a Python file (e.g., `example.py`) with functions, some with and some without type annotations. Run `flake8 example.py` from your terminal to see the reported issues regarding missing annotations.

import os

def my_function(arg1, arg2):
    # This function is missing type annotations
    return arg1 + arg2

def another_function(value: int) -> str:
    return str(value)

# To run flake8, save this as example.py and execute:
# flake8 example.py
# You should see errors like ANN001, ANN201 for my_function.

view raw JSON →