Skip to main content

Linter (flake8, pylint, custom CLI) for finding usage of deprecated functions.

Project description

flake8-warnings

Python linter that warns you about using deprecated modules, classes, and functions. It provides a CLI as well as flake8 and pylint plugins.

Usage

Installation:

python3 -m pip install flake8-warnings

Now, you can use it in one of the following ways:

  1. Directly from CLI: python3 -m flake8_warnings ./my_project/
  2. As a flake8 plugin. Just run flake8 ./my_project/, it will automatically detect the plugin.
  3. As a pylint plugin. For pylint, plugins must be explicitly specified: pylint --load-plugins=flake8_warnings ./my_project/.

How it works

It analyzes all imported modules, classes and functions and detects the following:

  1. warnings.warn function calls.
  2. Deprecation decorators like deprecated or deprecation.
  3. Deprecation messages in docstrings.
  4. Stdlib modules deprecated by PEP 594.

Error codes

The tool provides a different error code for each warning category:

  • 01: Warning
  • 02: UserWarning
  • 03: DeprecationWarning
  • 04: SyntaxWarning
  • 05: RuntimeWarning
  • 06: FutureWarning
  • 07: PendingDeprecationWarning
  • 08: ImportWarning
  • 09: UnicodeWarning
  • 10: BytesWarning
  • 11: ResourceWarning

This is how they are used in different linters:

  • In flake8, the code prefix is WS0, so DeprecationWarning will be reported as WS003.
  • In pylint, the prefix is W99, so DeprecationWarning will be reported as W9903. The "message-symbol" is the warning category. So, if you want to ignore an error about DeprecationWarning, add # pylint: disable=DeprecationWarning to this line.
  • If you use CLI, the warning category will be shown you directly, without any obscure codes.

In all cases, the error message is the detected warning message.

License

  1. flake8-wranings is licensed under MIT License. On practice, I don't care how you're going to use it. i did the project because it is fun, not because I want to be famous or whatever.
  2. astroid is a direct runtime dependency of flake8-warning and it is licensed under LGPL-2.1 License. It allows commercial and private usage, distribution and whatever, don't confuse it with GPL. However, if your legal department is still nervous, just don't make flake8-warnings a production dependency (why would you?), use it only on dev and test environments.

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-warnings-0.3.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

flake8_warnings-0.3.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file flake8-warnings-0.3.0.tar.gz.

File metadata

  • Download URL: flake8-warnings-0.3.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for flake8-warnings-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4e76de41ab93dd493e6f11f6d79bc50b6aecfece811426287ee4c19254da83d3
MD5 f198ff69950238ac2ce60feb8ae62ea9
BLAKE2b-256 7875873d1ebc2b254d0e3245a055fdfd4ece93ac917a4d5047f5e531717e7be9

See more details on using hashes here.

File details

Details for the file flake8_warnings-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_warnings-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e577405852a20dece9b52feffdfe0572e2fe59b74ddcc38f68c2016e8908e67
MD5 46f47325c0afc0d650e84f24775a826b
BLAKE2b-256 30012dee0144b51c27d2c057b2186433d0abfc27543974b2daeb9f37d20e0764

See more details on using hashes here.

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