Skip to main content

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

  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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_pyi-23.10.0.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

flake8_pyi-23.10.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file flake8_pyi-23.10.0.tar.gz.

File metadata

  • Download URL: flake8_pyi-23.10.0.tar.gz
  • Upload date:
  • Size: 52.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for flake8_pyi-23.10.0.tar.gz
Algorithm Hash digest
SHA256 f34ec4e1e892ee47f9608444e3675b71a5c9ccfe467bfbefc1a4882045a68794
MD5 f4cfdd75dcbe8c69ce23f052ec51b157
BLAKE2b-256 e08c5fae0a21c0a9de5efe2c499497984da54252767dd7708d9a7ac4585707b2

See more details on using hashes here.

Provenance

File details

Details for the file flake8_pyi-23.10.0-py3-none-any.whl.

File metadata

  • Download URL: flake8_pyi-23.10.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for flake8_pyi-23.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c2f912bc227e5694aeede463f2e9ecba7ffa0f8951f721f755eec5e492ed554
MD5 d8c92f8ba6630eaf4fdddb7d6d14dd07
BLAKE2b-256 e31df9b9d258adc2086883c4f9d8b1efddc500b0ba3165979db7a00d08d909a0

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page