Pylint Pytest Plugin
pylint-pytest is a Pylint plugin designed to suppress common false positives that arise when Pylint analyzes code written for Pytest, such as `unused-argument` for fixtures. The current version is 1.1.8, with active development including a v2.0.0 alpha series indicating ongoing significant updates and a regular release cadence.
Warnings
- breaking Versions 1.1.7 and later of `pylint-pytest` require Pylint v3 or newer due to backward-incompatible changes in Pylint's API. Users on older Pylint versions must upgrade Pylint or stick to `pylint-pytest < 1.1.7`.
- gotcha Version 1.1.8 of `pylint-pytest` has a known compatibility issue with `pytest` versions greater than `8.2.0` that can cause errors during linting.
- breaking Alpha versions for `pylint-pytest` 2.0.0 (e.g., v2.0.0a1) have dropped support for Python 3.8 and 3.9, aligning with broader dependency deprecations.
- deprecated The `pylint-pytest` plugin will raise a `W6401 deprecated-pytest-yield-fixture` warning if you use the `@pytest.yield_fixture` decorator, which is deprecated in Pytest.
Install
-
pip install pylint-pytest
Imports
- pylint_pytest
pylint --load-plugins pylint_pytest your_module.py
Quickstart
import pytest
def my_fixture():
return 42
def test_example(my_fixture):
"""This test uses a fixture, which Pylint might incorrectly flag as unused."""
assert my_fixture == 42
# To run pylint with the plugin:
# Save the above as `test_module.py`
# Then run: pylint --load-plugins pylint_pytest test_module.py