A plugin for flake8 to enable linting .pyi stub files.
Project description
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
-
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. -
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. -
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8_pyi-24.6.0.tar.gz
.
File metadata
- Download URL: flake8_pyi-24.6.0.tar.gz
- Upload date:
- Size: 61.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74847fe88dba8dc3ccd27091dc5dcbe8993d7616214e4084f33afe469a675b14 |
|
MD5 | f660a1453060f5f8c5c63ea4bf072f29 |
|
BLAKE2b-256 | 88452ee4b42f82310e177271b35e816d18ee60f1c9751f62e855c618572dfbc9 |
Provenance
File details
Details for the file flake8_pyi-24.6.0-py3-none-any.whl
.
File metadata
- Download URL: flake8_pyi-24.6.0-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b6366b666109ef9a2af54b724e76472f81bfeb97b3040906932b24a98a1d145 |
|
MD5 | b4692546b213e6699226221fac1639ba |
|
BLAKE2b-256 | 08ded1e7d3a88d2ec36cc63eeb350a3d04d5b9656d8c99f97f0a15fb2eae1e43 |