{"id":6201,"library":"pytest-pylint","title":"pytest-pylint","description":"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.","status":"active","version":"0.21.0","language":"en","source_language":"en","source_url":"https://github.com/carsongee/pytest-pylint","tags":["pytest","pylint","linter","testing","code quality","static analysis"],"install":[{"cmd":"pip install pytest-pylint","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for the plugin to function.","package":"pytest","optional":false},{"reason":"Required for performing static code analysis.","package":"pylint","optional":false}],"imports":[{"note":"pytest plugins extend pytest's behavior through entry points and hooks, rather than explicit Python imports in test files.","symbol":"pytest-pylint is a plugin and not typically imported directly in user code.","correct":"Functionality is enabled via `pip install pytest-pylint` and invoked using pytest command-line options or configuration."}],"quickstart":{"code":"import pytest\n\n# my_bad_module.py (example of code with a pylint warning)\ndef calculate(a, b):\n    result = a + b # W0612: Unused variable 'result'\n    return a + b\n\n# To run pylint with pytest, save the above in 'my_bad_module.py'\n# and create a dummy 'test_my_module.py' if needed for pytest discovery:\n# touch test_my_module.py\n\n# Then, run from your terminal:\n# pytest --pylint my_bad_module.py\n# Or to restrict error types:\n# pytest --pylint --pylint-error-types=E,F my_bad_module.py\n\n# Example .pylintrc content (optional, in project root):\n# [MESSAGES CONTROL]\n# disable=W0612\n\n# Example pytest.ini content (optional, in project root):\n# [pytest]\n# addopts = --pylint --pylint-error-types=E,F","lang":"python","description":"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)."},"warnings":[{"fix":"Upgrade pytest to >=7.0, Pylint to >=2.15, and Python to >=3.8 (or later depending on the specific pytest-pylint version).","message":"Version 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.","severity":"breaking","affected_versions":"0.20.0, 0.21.0 and later"},{"fix":"Use `pytest --pylint --pylint-error-types=E,F` or configure this in `pytest.ini` under `addopts`.","message":"By 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Properly configure `ignore` or `ignore-patterns` in your Pylint configuration file to prevent unwanted files from being scanned. Example: `[MASTER]\nignore-patterns=^\\.?\\w*conf\\.py, .*\\.md, .*\\.txt`","message":"Configuring 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Integrating `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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}