skillfed

flake8-pyi

A plugin for flake8 to enable linting .pyi stub files.

flake8-pyi v26.5.0 995.6K downloads/30d#4,550 on PyPI83
Permissive license MIT Active released

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-pyi

uv

uv add flake8-pyi

poetry

poetry add flake8-pyi

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleFramework :: Flake8Intended Audience :: DevelopersOperating 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 :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

flake8 stub file lintingpyi file type checkingtypeshed style enforcementstub file linter pluginpython type stub validationpyi linting rulesflake8 type stubs
type-stubsflake8-plugintypeshed

More Python Modules packages