flake8-pyi

25.5.0 · active · verified Wed Apr 15

flake8-pyi is a plugin for Flake8 that specializes in linting `.pyi` stub files. It enforces type-hinting best practices and adheres to the typeshed style guide, providing specific warnings (codes starting with Y0). The library is actively maintained, with frequent releases that often introduce new error codes and adapt to changes in Python's typing ecosystem. The current version is 25.5.0.

Warnings

Install

Quickstart

To use flake8-pyi, first install both `flake8` and `flake8-pyi`. Then, you can run `flake8` directly on your `.pyi` files or your project directory. flake8-pyi automatically applies its checks to `.pyi` files. Configuration, such as enabling disabled error codes or ignoring others, can be managed in a `pyproject.toml` (under `[tool.flake8]`), `setup.cfg`, `tox.ini`, or `.flake8` file.

import os

# example.pyi
# def foo(x: int) -> str:
#     ...

# Configure flake8 to use flake8-pyi (e.g., in pyproject.toml):
# [tool.flake8]
# max-line-length = 88
# extend-ignore = E203, W503
# extend-select = Y090 # Example: enable Y090 which is disabled by default

# To run flake8 with flake8-pyi:
# flake8 example.pyi
# or for an entire project:
# flake8 .

view raw JSON →