@codacy/tools-pylint-4
Table of Contents
Overview
Python static analyzer using the Pylint binary. Uses the CLI execution strategy — installs pylint into a dedicated venv, spawns it via spawnTool(), and parses its JSON2 output.
| Property | Value |
|---|---|
| Tool ID | PyLintPython3 |
| Codacy UUID | 31677b6d-4ae0-4f56-8041-606a8d7a8e61 |
| Strategy | CLI |
| Languages | Python |
| Binary | pylint |
| File patterns | **/*.py |
| Pattern count | ~340 |
| Prerequisites | Python 3.10+ |
Updating patterns
# Re-fetch pattern metadata from the Codacy API
pnpm prefetch
# Commit the result
git add src/patterns.json
Pattern IDs follow the format PyLintPython3_C0114, PyLintPython3_E0602, etc.
Updating the Pylint version
- Update
PREFERRED_VERSIONand thepylint==X.Y.Zentry inPIP_PACKAGESinsrc/adapter.ts - Run
pnpm prefetchto check for new/removed rules - Run
pnpm testto verify compatibility - If the major version changes, create a new adapter package (
pylint-4/)
Development
pnpm build # Build with tsup
pnpm test # Run tests (requires pylint in PATH or auto-installed)
Install pylint manually for local development:
pip install pylint
Or let the adapter auto-install into a venv:
codacy-analysis analyze . --install-dependencies
The adapter installs these packages into the venv:
pylint==4.0.8pylint-djangopylint-flaskpylint-celerypylint-commonpylint-beampylint-pytestSaltPyLint
Notes for maintainers
- JSON2 output format: The adapter uses
--output-format=json2which outputs{ "messages": [...], "statistics": {...} }. This is the modern format (Pylint 3.x+). - 0-based columns: Pylint reports columns as 0-based. The adapter adds 1 to convert to the 1-based model used by Codacy.
- Nullable endLine/endColumn: These fields can be
nullin Pylint output. The adapter omits them from Issue objects when null. - Exit code bitmask: Pylint uses a bitmask exit code. Bit 5 (value 32) indicates a usage error (bad config/args). Bits 0-4 (values 1-31) indicate normal findings. The adapter checks
exitCode & 32to distinguish errors from normal findings. - E0401 filtering: The
E0401(import-error) pattern is permanently filtered because sandboxed environments cannot resolve third-party imports. This matches the existing Codacy wrapper behavior. - Plugin support: The adapter bundles the same plugins as the Codacy wrapper (pylint-django, pylint-flask, pylint-celery, pylint-common, pylint-beam, pylint-pytest, SaltPyLint).
- Pattern parameters: Some patterns accept parameters (e.g.
max-line-lengthfor C0301,max-localsfor R0914). These are passed as--{param}={value}CLI arguments. - Python 3.10+: pylint 4 dropped 3.9, so
installpasses>=3.10.0toensurePython(an older system Python, e.g. Apple's 3.9/usr/bin/python3, is skipped and a portable 3.12 is downloaded) and toensureVenv(a venv an earlier install built on 3.9 is rebuilt, not reused). - Venv isolation: Pylint and its plugins are installed in a dedicated venv at
~/.codacy/runtimes/PyLintPython3/venv/to avoid dependency conflicts with other Python tools. The path is keyed on the stable tool ID rather than the package folder name, so a major bump keeps the venv and upgrades it in place instead of orphaning it. - Config files: The adapter reports
pylintrcor.pylintrc(in that order) as a local configuration file, and nothing else. Codacy Cloud accepts only those two names, sopyproject.toml,setup.cfg,tox.iniandpylintrc.tomlnever count, even with a Pylint section. Pylint still reads them at run time for its other settings.