Skip to main content

flake8-pyi

A plugin for Flake8 that provides specializations for type hinting stub files, especially interesting for linting typeshed.

Refer to this documentation for more details on stub files.

Functionality

  1. Adds the .pyi extension to the default value of the --filename command-line argument to Flake8. This means stubs are linted by default with this plugin enabled, without needing to explicitly list every file.

  2. Modifies PyFlakes runs for .pyi files to defer checking type annotation expressions after the entire file has been read. This enables support for first-class forward references that stub files use.

  3. Provides a number of .pyi-specific warnings that enforce typeshed's style guide.

Note: Be careful when using this plugin in the same environment as other flake8 plugins, as they might generate errors that are inappropriate for .pyi files (e.g., about missing docstrings). We recommend running flake8-pyi in a dedicated environment in your CI.

Lints provided

This plugin reserves codes starting with Y0. For a full list of lints currently provided by flake8-pyi, see the list of error codes.

Note that several error codes recommend using types from typing_extensions or _typeshed. Strictly speaking, these packages are not part of the standard library. However, these packages are included in typeshed's stdlib/ directory, meaning that type checkers believe them to be part of the standard library even if this does not reflect the reality at runtime. As such, since stubs are never executed at runtime, types from typing_extensions and _typeshed can be used freely in a stubs package, even if the package does not have an explicit dependency on either typing_extensions or typeshed.

Flake8-pyi's checks may produce false positives on stubs that aim to support Python 2.

License

MIT

Authors

Originally created by Łukasz Langa and now maintained by Jelle Zijlstra, Alex Waygood, Sebastian Rittau, Akuli, and Shantanu.

See also

Release files for flake8-pyi 26.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-pyi 26.5.0
File Size Uploaded
flake8_pyi-26.5.0.tar.gz 61.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-pyi 26.5.0
File Interpreter ABI Platform
flake8_pyi-26.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 86.4 kB

Release files / flake8_pyi-26.5.0.tar.gz

Download URL flake8_pyi-26.5.0.tar.gz
Size 61.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6e846efa7bdf4221cbf35c5123b8e8882ab1220578e89db2294a077368ac4885
BLAKE2b-256 checksum
How to use checksums
288dc31a6bd3d74a4ec81c7d52ca50ce51288b60f50b39d36cbf3eee4bfbd88b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / flake8_pyi-26.5.0-py3-none-any.whl

Download URL flake8_pyi-26.5.0-py3-none-any.whl
Size 25.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24fa143364f78d919930d04f9d99e01ac6666c096f9d01eb9436c469a5b777cb
BLAKE2b-256 checksum
How to use checksums
33141c30394b49b7e600c12d89e1fe3c33dbec0b1b0532a0f16ccb5eab403b78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

26.5.0 This release

2 release files

25.5.0

2 release files

24.9.0

2 release files

24.6.0

2 release files

24.4.1

2 release files

24.4.0

2 release files

24.3.1

2 release files

24.3.0

2 release files

23.6.0

2 release files

23.4.1

2 release files

23.4.0

2 release files

23.3.1

2 release files

23.3.0

2 release files

23.1.2

2 release files

23.1.1

2 release files

23.1.0

2 release files

22.8.2

2 release files

22.7.0

2 release files

22.5.1

2 release files

22.5.0

2 release files

22.4.1

2 release files

22.4.0

2 release files

22.3.0

2 release files

22.2.0

2 release files

22.1.0

2 release files

20.5.0

2 release files

19.2.0

2 release files

18.3.1

2 release files

18.3.0

2 release files

17.3.0

2 release files

17.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page