Lint
http://www.pylint.org
pip install pylint
Checking line-code's length,
Checking if variable names are well-formed according to your coding standard
Checking if imported modules are used
Usage:
pylint script.py
To decipher warnings and other messages:
http://pylint-messages.wikidot.com/all-codes
Also it is possible to force pylint to ignore some rule checks:
In comments in your code before code to ignore:
# pylint: disable=C0321
Create/use pylint config file with all needed settings:
CLI
Two most useful command examples:
Stop the build if there are Python syntax errors or undefined names.
Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide.
The arguments can be moved to a config as well.
Config
Flake8
supports storing its configuration in the following places:
Your top-level user directory. In your project in one of setup.cfg, tox.ini, or .flake8. Example:
or
Error status codes
The symbol associated with a specific check. For example, pycodestyle implements checks that look for whitespace around binary operators and will either return an error code of W503 or W504.
Using Flake8
gives error codes from Flake8
and the lower level PyCode
project.
Flake8 docs
Flake8 errors start with F - F4XX, F5XX, F6XX, F8XX and F901.
PyCode style
E errors - EXXX.
W warnings - WXXX. It looks like these are mostly taken care of by using an IDE to format the code and not using any deprecated code patterns.
100 indentation
200 whitespace
300 blank lines
400 imports
500 line length
600 deprecation
700 statements
900 syntax error
Examples:
Ruff
⚡️ 10-100x faster than existing linters
🐍 Installable via pip
🤝 Python 3.11 compatibility
📦 Built-in caching, to avoid re-analyzing unchanged files
🔧 Autofix support, for automatic error correction (e.g., automatically remove unused imports)
📏 Over 500 built-in rules
⚖️ Near-parity with the built-in Flake8 rule set
🔌 Native re-implementations of dozens of Flake8 plugins, like flake8-bugbear
⌨️ First-party editor integrations for VS Code and more
Installation:
Usage
CLI commands examples:
Config
Configuration can be done via pyproject.toml, ruff.toml, or .ruff.toml:
VS Code extension
Once installed in Visual Studio Code, ruff will automatically execute when you open or edit a Python file.
Interesting commands among others:
"Fix all": automatically fix all auto-fixable violations
"Organize Imports": isort-compatible import sorting
Last updated