Coder Social home page Coder Social logo

orsinium-labs / flake8-warnings Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 2.0 48 KB

Python linter (flake8, pylint, CLI) that warns you about using deprecated modules, classes, and functions

License: Other

Python 100.00%
python python3 flake8 flake8-plugin flake8-extensions flake8-plugins flake8-extension qa linter code-quality clean-code security pylint

flake8-warnings's Introduction

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.

flake8-warnings's People

Contributors

aliaksei-protchanka avatar orsinium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.