Registry / testing / pylint

pylint

JSON →
library4.0.7pypypi✓ verified 28d ago

Pylint is a widely used static code analyzer for Python. It inspects source code without execution to detect programming errors, enforce coding standards (like PEP 8), identify code smells, and suggest refactorings. It provides a detailed report and a code quality score. Pylint maintains an active development status with regular releases, including minor versions for new checks and bug fixes, and major versions that may introduce breaking changes to options or output formats.

pip install pylint
INSTALL
IMPORT
SIG · PYLINT
P
pylint
testingpythonv4.0.7
Install
2.7s avg
Import
500ms
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.0.7 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.512s · 27.3MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 2.7s · import 0.488s · 28MB
26MB installed
● package 26MB
Code
Verified usage

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

Run
✓ from pylint.lint import Run
Used for programmatic invocation of Pylint.
TextReporter
✓ from pylint.reporters.text import TextReporter
Useful for capturing Pylint's output to a custom stream when running programmatically.

The most common way to use Pylint is via the command line, simply by pointing it to a Python file, module, or package. For integration into tools or CI/CD pipelines, Pylint can also be invoked programmatically using `pylint.lint.Run`, allowing for custom reporters and output handling. The quickstart demonstrates both methods.

import os import io from pylint.lint import Run from pylint.reporters.text import TextReporter # Create a dummy Python file for linting with open('my_module.py', 'w') as f: f.write('"""A simple module.""" MY_CONSTANT = 10 def my_function(arg1, arg2): # arg2 is unused return arg1 + MY_CONSTANT ') # --- Command Line Usage --- print("\n--- Command Line Pylint ---") os.system('pylint my_module.py') # --- Programmatic Usage --- print("\n--- Programmatic Pylint ---") # Capture output to a string buffer pylint_output = io.StringIO() reporter = TextReporter(pylint_output) # Run Pylint on the module, disabling reports for cleaner output # do_exit=False prevents sys.exit() on linting issues Run(['my_module.py', '--disable=C0114,C0116,R0903', '--reports=no'], reporter=reporter, do_exit=False) print(pylint_output.getvalue()) # Clean up the dummy file os.remove('my_module.py')
pylint --version
Debug
Known issues
breakingPylint 4.x removes direct access to package metadata via `pylint.__pkginfo__`. Users should migrate to `importlib.metadata` for retrieving package information.
fix
Replace `from pylint import __pkginfo__` with `from importlib import metadata; metadata.metadata('pylint')`.
affects: 4.0.0+
breakingPylint 4.x officially drops support for *launching* Pylint with Python 3.9. While it can still *lint* code written for Python 3.9 (or older) using `--py-version=3.9`, the environment running Pylint itself must be Python 3.10.0 or newer.
fix
Ensure that the Python interpreter used to install and run Pylint is 3.10.0 or newer. If linting older Python code, use the `--py-version` flag.
affects: 4.0.0+
breakingIn Pylint 3.x, the behavior of enabling or disabling individual messages changed. The order of `--enable` or `--disable` flags (or their counterparts in configuration files) now strictly dictates their application, meaning later options can override earlier ones.
fix
Review configuration files and command-line arguments to ensure the intended message enabling/disabling order is maintained. Avoid redundant or conflicting `enable=all`/`disable=all` with specific message controls.
affects: 3.0.0+
gotchaPylint's default configuration can be very verbose, especially on legacy or less-PEP 8 compliant projects. This often leads to an overwhelming number of messages upon first run.
fix
During initial adoption, start with `--errors-only` or disable convention/refactor messages (e.g., `--disable=C,R`) and progressively re-enable checks as code quality improves. Generate a `.pylintrc` file (`pylint --generate-rcfile > .pylintrc`) for granular control over messages and checkers.
affects: All versions
gotchaThe `invalid-name` message often triggers due to Pylint's default expectation of `UPPERCASE` for module-level constants, which might conflict with project-specific naming conventions.
fix
Customize the regular expressions for naming conventions in your `.pylintrc` file. For instance, modify `--const-rgx` or `--variable-rgx` to match your project's style.
affects: All versions
gotchaPylint relies on Python's module resolution mechanism. Incorrect `PYTHONPATH` settings or running Pylint from an unexpected working directory can lead to it analyzing the wrong module version or failing to import modules, resulting in `import-error` messages.
fix
Always run Pylint from the project root or a directory where Python can correctly resolve your modules. Verify your `PYTHONPATH` environment variable if encountering import issues.
affects: All versions
breakingThe Python script being linted contains a fundamental `SyntaxError`, preventing Pylint from analyzing the code. Pylint cannot process files that are not valid Python.
fix
Before running Pylint, ensure that the target Python script is free of basic syntax errors. Correct the `SyntaxError` in the script as indicated by the Python interpreter (e.g., unclosed string literals, unmatched parentheses/brackets).
affects: All versions
gotchaThe script executed as part of the test setup contains a fundamental Python syntax error, preventing its successful execution. This is independent of Pylint's behavior or specific version.
fix
Correct the syntax error in the relevant Python script (e.g., ensure all string literals are properly terminated) before attempting to run the test or Pylint.
affects: All versions
Errors
Common errors & fixes
missing-module-docstring
Pylint requires Python modules to have a docstring at the beginning of the file to explain the module's purpose, as per coding style conventions like PEP 257.
fix
Add a triple-quoted string (docstring) at the very top of your Python file, after the shebang but before any code or imports. 
```python
"""A brief description of what this module does."""

# Your code starts here
import os
```
pylint Unable to import
Pylint cannot find the specified module because it's not in Python's `sys.path`, often due to an incorrect virtual environment, a custom module not being on the path, or a misspelled import statement.
fix
Ensure the module is installed in the correct environment (e.g., `pip install your-module`). If it's a local module, ensure its containing directory is on the `PYTHONPATH` or configure Pylint's `init-hook` in `.pylintrc` to add the path. For Visual Studio Code, select the correct Python interpreter for your project.
pylint no-name-in-module (E0611)
Pylint reports this error when a specific name (function, class, variable) imported from a module cannot be found within that module. This can happen if the name is misspelled, not actually exported by the module, or if Pylint has trouble analyzing the module due to complex imports or dynamic code.
fix
Double-check the spelling of the imported name. Verify that the name is indeed available in the module you are importing from. If it's a dynamic import or Pylint's analysis is failing, you might need to add `ignored-modules` or `generated-members` to your `.pylintrc` or use an inline disable comment `# pylint: disable=no-name-in-module`.
pylint unused-import (W0611)
This warning occurs when a module or a specific name imported from a module is not used anywhere in the code that follows the import statement, indicating potentially unnecessary code.
fix
Remove the unused import statement. If the import is necessary for some reason (e.g., for side effects or for a `__init__.py` exposing submodules), you can disable the warning for that specific line or file using `# pylint: disable=unused-import` or configure `good-names` for specific cases.
pylint: command not found
The 'pylint' command is not recognized by your system's shell because the directory where Pylint is installed is not included in your system's PATH environment variable, or Pylint was not installed correctly.
fix
Ensure Pylint is installed in your current Python environment (`pip install pylint`). If installed, locate the Pylint executable (often in `Scripts/` on Windows or `bin/` in a Unix-like environment within your Python installation or virtual environment) and add that directory to your system's PATH. Alternatively, run Pylint using `python -m pylint [options] <files>`.
Upgrade
Version history
4.0.7latest on PyPI · released Aug 9, 2026
Audit
Dependencies
astroidrequiredPylint's core for Abstract Syntax Tree (AST) inference and representation.
isortrequiredVersion requirement for isort was bumped to >=5.0.0 in Pylint 4.x releases.
Agent activity
13 hits · last 30 days
node
11
Resources
pylint — pip install pylint · libregistry