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:
- Directly from CLI:
python3 -m flake8_warnings ./my_project/
- As a flake8 plugin. Just run
flake8 ./my_project/
, it will automatically detect the plugin. - 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:
- warnings.warn function calls.
- Deprecation decorators like deprecated or deprecation.
- Deprecation messages in docstrings.
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
, soDeprecationWarning
will be reported asWS003
. - In pylint, the prefix is
W99
, soDeprecationWarning
will be reported asDeprecationWarning
. The "message-symbol" is the warning category. So, if you want to ignore an error aboutDeprecationWarning
, 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
- 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.
- 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.2.0.tar.gz
(10.4 kB
view hashes)
Built Distribution
Close
Hashes for flake8_warnings-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df30f5cf4702162f233b576e3c85f5e4f287e37d5d72d2dfaff00aff806262a5 |
|
MD5 | 6d322b57765da70d0516f1f76c22fcfd |
|
BLAKE2b-256 | 54c5f112c40d1dfc1b19c175bc70f0a99401eeaff53b0ff43b08450b2433ad6c |