Run pylint with pytest and have configurable rule types (i.e. Convention, Warn, and Error) fail the build. You can also specify a pylintrc file.
py.test --pylint
would be the most simple usage and would run pylint for all error messages.
py.test --pylint --pylint-rcfile=/my/pyrc --pylint-error-types=EF --pylint-jobs=4
This would use the pylintrc file at /my/pyrc, only error on pylint Errors and Failures, and use 4 cores for running pylint.
You can restrict your test run to only perform pylint checks and not any other tests by typing:
py.test --pylint -m pylint
This code is heavily based on pytest-flakes
If you want to help development, there is overview documentation
- Dropped support for pytest < 7.0 in preparation for pytest 8.0 (should work with it when it comes out)
- Dropped support for pylint < 2.15 to work better with Python 3.11 and drop backwards compatibility code
- Use baked in TOML support with fallback to newer tomli library thanks to mgorny
- Corrected issues introduced by deprecations in pylint
- Added support for Python 3.12 and dropped support for Python 3.7
- Last version that will support pytest < 7 and pylint < 2.6
- Switched to GitHub Actions for CI thanks to michael-k
- Switched to using smart PyLint RC discovery thanks to bennyrowland
- Correcting rootdir/rootpath issues in pytest >7.x
- Deprecated support for Python <3.7
- Added support for creating missing folders when using
--pylint-output-file
- Now when pylint's
ignore_patterns
is blank, we don't ignore all files - Added cache invalidation when your pylintrc changes
- Verified support for latest pytest and Python 3.9
- Corrected badly named nodes (duplicated path) thanks to yanqd0
- Added tests to source distribution thanks to sbraz
- Added support for latest pylint API >=2.5.1
- Corrected documentation and correctly pinned dependencies properly
- Switched to new
from_parent
API and added development documentation dineshtrivedi - Added support for toml based configuration of pylint thanks to michael-k
- Made --no-pylint functional again
- Added support for Python 3.8 thanks to michael-k
- Implemented option to output Pylint results to a reports file thanks to jose-lpa
- Refactored into simpler plugin structure
- Corrected pytest-pylint to properly support
-p no:cacheprovider
thanks to yanqd0
- Added support for Pylint's ignore-patterns for regex based ignores thanks to khokhlin
- pytest-pylint now caches successful pylint checks to speedup test reruns when files haven't changed thanks to yanqd0
- Python 3.7 compatibility verified
- Ignore paths no longer match partial names thanks to heoga
- jamur2 corrected issue where file paths where not being output properly on lint failures.
- Resolved issue where failing files weren't reported thanks to reports from skirpichev and jamur2
- Corrected a bug preventing this plugin from working with py.test >= 3.7.0.
- jwkvam added progress output during linting.
- Added option
--no-pylint
to override--pylint
for cases when it's turned on by default.
- jwkvam provided support for pylint 2.0
- noisecapella added an option to run pylint with multiple processes
- bdrung corrected inconsistent returns in a function
- Dropped Python 3.3 support
- Corrected path issue reported by Kargathia
- Linting is performed before tests which enables code duplication checks to work along with a performance boost, thanks to @heoga