Registry / testing / pytest-pylint

pytest-pylint

JSON →
library0.21.0pypypiunverified

pytest-pylint is a pytest plugin that integrates Pylint, a Python static code analysis tool, into the pytest testing framework. It allows developers to run Pylint checks as part of their test suite, ensuring code quality and adherence to coding standards. The library is actively maintained, with regular updates to support newer versions of pytest, Pylint, and Python. The current version is 0.21.0.

pip install pytest-pylint
INSTALL
IMPORT
SIG · PYTEST-PYLINT
P
pytest-pylint
testingpythonv0.21.0
Install
3.8s avg
Import
—
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.21.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 39.3MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 3.8s · import 0.000s · 40MB
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest-pylint is a plugin and not typically imported directly in user code.
✓ Functionality is enabled via `pip install pytest-pylint` and invoked using pytest command-line options or configuration.
pytest plugins extend pytest's behavior through entry points and hooks, rather than explicit Python imports in test files.

To use pytest-pylint, simply install it. It automatically integrates with pytest. You can then run pytest with the `--pylint` flag to enable Pylint checks. For more control, use `--pylint-rcfile` to specify a Pylint configuration file (e.g., `.pylintrc`) or `--pylint-error-types` to filter which message types cause a test failure (e.g., 'E' for error, 'F' for fatal, 'W' for warning, 'C' for convention, 'R' for refactor).

import pytest # my_bad_module.py (example of code with a pylint warning) def calculate(a, b): result = a + b # W0612: Unused variable 'result' return a + b # To run pylint with pytest, save the above in 'my_bad_module.py' # and create a dummy 'test_my_module.py' if needed for pytest discovery: # touch test_my_module.py # Then, run from your terminal: # pytest --pylint my_bad_module.py # Or to restrict error types: # pytest --pylint --pylint-error-types=E,F my_bad_module.py # Example .pylintrc content (optional, in project root): # [MESSAGES CONTROL] # disable=W0612 # Example pytest.ini content (optional, in project root): # [pytest] # addopts = --pylint --pylint-error-types=E,F
Debug
Known issues
breakingVersion 0.21.0 dropped support for pytest versions older than 7.0 and Pylint versions older than 2.15. Version 0.20.0 was the last to support Python 3.7 and Pylint < 2.6. Ensure your environment meets the minimum version requirements.
fix
Upgrade pytest to >=7.0, Pylint to >=2.15, and Python to >=3.8 (or later depending on the specific pytest-pylint version).
affects: 0.20.0, 0.21.0 and later
gotchaBy default, `--pylint` runs Pylint for all message types. This can lead to many 'failures' from convention or refactor messages. To make Pylint failures more strict, configure `--pylint-error-types` to specify which message types (e.g., Errors and Fatal) should cause the pytest run to fail.
fix
Use `pytest --pylint --pylint-error-types=E,F` or configure this in `pytest.ini` under `addopts`.
affects: All versions
gotchaWhen trying to run only Pylint checks and no other tests using `pytest --pylint -m pylint`, pytest might still attempt to collect other test modules. If these modules have import issues or other collection-time errors, pytest may report them, even though you intended to skip their execution.
fix
Ensure that all Python files in your test discovery path are syntactically valid and have resolvable imports, even if they contain no tests or are explicitly marked for skipping. Address any PythonPath issues for test files.
affects: All versions
gotchaConfiguring Pylint's `ignore-patterns` in a `.pylintrc` or `pyproject.toml` file is crucial for excluding non-Python files, generated code, or specific directories from linting. Incorrect configuration can lead to Pylint trying to parse unexpected file types or linting irrelevant code.
fix
Properly configure `ignore` or `ignore-patterns` in your Pylint configuration file to prevent unwanted files from being scanned. Example: `[MASTER]
ignore-patterns=^\.?\w*conf\.py, .*\.md, .*\.txt`
affects: All versions
gotchaIntegrating `pytest-pylint` with `pytest-xdist` (for parallel test execution) might lead to performance degradation or unexpected behavior in some scenarios. Users have reported slowdowns when `xdist` is enabled with `pytest-pylint`.
fix
If performance is an issue, consider running Pylint separately from other parallelized tests, or investigate specific configurations for `pytest-xdist` that might mitigate the slowdown. Consult the GitHub issues for potential workarounds.
affects: All versions
Upgrade
Version history
0.21.0latest on PyPI · released Oct 6, 2023
Audit
Dependencies
pytestrequiredRequired for the plugin to function.
pylintrequiredRequired for performing static code analysis.
Agent activity
15 hits · last 30 days
node
12
Resources
pytest-pylint — pip install pytest-pylint · libregistry