Pylint
Pylint is a static code analysis tool, or linter, for Python that detects issues, enforces conventions, and offers refactoring guidance. Its checks encode Pythonic idioms and general programming best practices, so it surfaces code smells and questionable patterns in addition to outright errors.
Installation and Setup
Install it from the Python Package Index (PyPI) into a virtual environment:
Configuration can live in pyproject.toml or a .pylintrc file at the project root. In pyproject.toml, section names must be prefixed with tool.pylint., as in [tool.pylint.'MESSAGES CONTROL']. You can bootstrap a configuration file with:
$ python -m pylint --generate-rcfile > .pylintrc
$ python -m pylint --generate-toml-config >> pyproject.toml
Key Features
- Detects programming errors, such as undefined names, unused variables, import issues, and unreachable code.
- Infers the actual values of names and expressions with its
astroidcode representation instead of trusting type hints, so it catches issues in code that isn’t fully typed. - Checks coding style and naming conventions and can be tuned to match project guidelines.
- Provides refactoring hints and code smell warnings, along with a summary report and score.
- Is highly configurable with per-project, per-file, and per-line control of messages and rules, and is extensible through plugins, either custom checks or existing ones for popular frameworks and third-party libraries.
- Integrates with editors and continuous integration (CI) systems through standard command-line usage and exit codes.
Usage
Analyze a module, package, or file path:
$ python -m pylint path/to/package
Limit output to errors only:
$ python -m pylint --errors-only path/to/file.py
Enable or disable specific checks on the command line:
$ python -m pylint -d C0114 -e E0602 module_name.py
Silence a check inline for a single line or block:
def greet(name):
# pylint: disable=unused-argument
print("Hello")
Generate a summary report for a package:
$ python -m pylint --reports=y package/
Related Resources
Course
Writing Cleaner Python Code With PyLint
In this video series you'll see how to install and set up the PyLint code linter tool. You'll learn why you should use code linters like PyLint, Flake8, PyFlakes, or other static analysis tools—and how they can help you write cleaner and more Pythonic code.
For additional information on related topics, take a look at the following resources:
- Python Code Quality: Best Practices and Tools (Tutorial)
- Ruff: A Modern Python Linter for Error-Free and Maintainable Code (Tutorial)
- Managing and Measuring Python Code Quality (Course)
- Python Code Quality: Best Practices and Tools (Quiz)
- Modern Python Linting With Ruff (Course)
- Ruff: A Modern Python Linter (Quiz)
By Leodanis Pozo Ramos • Updated Sept. 11, 2026