flake8-pyi
A plugin for flake8 to enable linting .pyi stub files.
What it is and what it does
flake8-pyi is a Flake8 plugin designed specifically for linting Python type stub files (.pyi). It extends Flake8 to automatically include .pyi files in linting runs and modifies PyFlakes to handle forward references correctly—a feature essential for stub files where types are declared but never executed. The plugin enforces typeshed's style guide through a set of stub-specific lint rules (prefixed with Y0) that catch patterns inappropriate for stub files.
The plugin is most useful in CI pipelines for projects that maintain type stubs, particularly typeshed itself. It runs on modern Python versions and has minimal dependencies. The documentation notes that running it in a dedicated CI environment is recommended to avoid conflicts with other Flake8 plugins that may flag issues irrelevant to stub files (like missing docstrings).
Use it for:
- Lint typeshed stub files in CI to enforce consistent style and catch type annotation errors before merging.
- Validate custom .pyi stub files in a project's type stubs package without manual review of every file.
- Catch forward-reference issues in stub files that would be missed by standard Flake8 and PyFlakes.
- Enforce typeshed conventions in stub-heavy projects to maintain consistency across many .pyi files.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Flake8 plugin that lints Python type stub files (.pyi) with stub-specific rules and forward-reference support, enforcing typeshed style conventions.
Yes, if you maintain or contribute to type stub files (.pyi). The plugin is actively maintained, has no known vulnerabilities, and solves a real problem—standard linters are not designed for stub files. Install in a dedicated CI environment to avoid conflicts with other Flake8 plugins. Not necessary for projects that do not use stub files.
Install
flake8-pyi on PyPI
pip
pip install flake8-pyiuv
uv add flake8-pyipoetry
poetry add flake8-pyiInstalling flake8-pyi
Before you install
Low friction install with just two runtime dependencies (flake8 and pyflakes). Repository is actively maintained with recent commits and a stable release history since 2016.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for any project type.
Quickstart
pip install flake8-pyi
flake8 --filename='*.pyi' your_stubs/
Requires Python 3.10 or later; flake8 and pyflakes must be installed as runtime dependencies.
Verify before relying
- Whether the Y0-prefixed error codes cover all common stub-file style issues or if some require manual review.
- Performance impact when running flake8-pyi alongside other plugins in the same environment.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — flake8, pyflakes |
| Maintenance | actively maintained — 95 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 995,574/month — #4,550 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_pyi-26.5.0-py3-none-any.whl
Keywords: bugs, flake8, linter, pyflakes, pyi, qa, stubs, typing
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
dlintDlint is a flake8 plugin that adds…
permissive · top 15,000 on PyPI
flake8-bugbearA flake8 plugin that detects likely bugs and…
permissive · top 5,000 on PyPI
flake8Flake8 is a command-line tool that combines…
permissive · top 1,000 on PyPI
types-pyflakesProvides type stubs for the pyflakes static…
permissive · top 15,000 on PyPI
flake8-annotationsA Flake8 plugin that enforces PEP 3107-style…
permissive · top 15,000 on PyPI
flake8-type-checkingA flake8 plugin that identifies which imports…
permissive · top 15,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI
flake8-banditIntegrates bandit security checks into flake8…
permissive · top 15,000 on PyPI
flake8-jsonA Flake8 plugin that formats linting output as…
permissive · top 15,000 on PyPI
flake8-tupleA flake8 plugin that detects unintended…
permissive · top 15,000 on PyPI