Python linters are tools that analyze Python code for potential errors, style violations, and improvements in code quality. They help enforce coding standards, identify bugs, and suggest refactoring. Popular Python linters include Pylint (for comprehensive checks), Flake8 (lightweight error detection), and Black (strict code formatting). Linters help you keep code clean, efficient and bug-free.
In short, the best Python linters setup in 2026 is Ruff for fast linting and formatting, plus Pylint when you want deeper checks such as design smells and refactoring hints. Black is still the reference formatter, and Ruff’s formatter follows the same style, so most projects now use either Black or ruff format, not both.

Key takeaways
- Pylint: slowest but deepest analysis, with refactoring (R) and design messages and custom plugins.
- Black: an opinionated formatter only. It changes layout, never logic.
- Ruff: a Rust-based linter and formatter, which its docs describe as “10-100x faster than existing linters (like Flake8) and formatters (like Black)”.
- Commands changed: use
ruff checkandruff format; the bareruff file.pyform no longer works. - Pylint 3.0 removed
IAstroidCheckerand__implements__; older plugin code needs a small update (shown below).
1. Introduction to Code Linters
While working with bigger software projects, maintaining code quality is essential. Code linters are tools that help developers enforce coding standards, detect potential errors, and ensure that code is maintainable in the long term. In Python, there are several tools available that help with this, including Pylint, Black, and Ruff.
- Pylint is a powerful static code analysis tool for Python that checks for errors, enforces coding standards, and suggests refactoring improvements.
- Black is an opinionated code formatter that formats Python code to follow consistent style guidelines, focusing purely on the formatting aspect without checking logic.
- Ruff is a fast Python linter and formatter that focuses on speed and performance in static analysis.
By using these tools together, developers can significantly enhance the readability, consistency, and quality of their Python code.
2. What is Pylint?
Pylint is one of the most comprehensive tools available for static code analysis in Python. It provides feedback on potential errors, enforces coding standards based on PEP8, and suggests code refactoring where necessary. Unlike some linters that only focus on syntax or style, Pylint also checks for deeper issues such as logical errors, unused imports, and more.
How Does Pylint Work?
Pylint works by analyzing Python code without running it. It parses the code into an abstract syntax tree (AST) and uses this representation to identify potential issues. This includes syntax errors, logical flaws, and stylistic inconsistencies.
Pylint Features
- PEP8 Compliance: Enforces Python’s official style guide.
- Error Detection: Detects coding errors such as undefined variables, wrong function signatures, etc.
- Code Smell Detection: Identifies parts of the code that may need refactoring.
- Metrics Generation: Provides metrics such as cyclomatic complexity, number of lines, and docstring percentage.
- Extensibility: Can be extended with custom plugins to add more checks.
- Customization: Supports extensive configuration to tailor checks to specific projects.
Installing and Running Pylint
To install Pylint, use pip:
pip install pylint
To run Pylint on a Python file or project:
pylint my_python_file.py
Pylint will output a detailed report of errors, warnings, and suggestions, each marked with a unique identifier.
3. Understanding Pylint Messages
Pylint divides its feedback into several categories, each indicating a different level of severity or type of problem.
Categories of Messages
- Errors (E): Indicate critical issues in the code that will likely cause it to fail.
- Warnings (W): Highlight potential problems, such as bad practices or possible runtime issues.
- Refactors (R): Suggest improvements in code structure and efficiency.
- Conventions (C): Check for code style and adherence to PEP8.
Common Pylint Errors and How to Fix Them
- E1101 (no-member): Occurs when Pylint believes you’re trying to access a method or attribute that doesn’t exist.
- W0611 (unused-import): Indicates an import statement that is not used anywhere in the code.
- C0111 (missing-docstring): Warns that a function or class is missing a docstring. In current Pylint versions this check is split into C0114 (missing-module-docstring), C0115 (missing-class-docstring) and C0116 (missing-function-docstring).
Each message is accompanied by a detailed description and a suggested fix, making it easier to correct the issues.
4. Comparison with Black and Ruff
While Pylint provides comprehensive code analysis, Black and Ruff are other popular tools that focus on specific areas of code quality. Let’s compare them to understand how they complement each other.
What is Black?
Black is an opinionated Python code formatter. Unlike Pylint, which checks for a wide range of issues, Black only focuses on reformatting Python code according to its own style guide. Once you run Black on your code, it will be formatted consistently according to the tool’s strict rules.
- Black is highly opinionated and leaves little room for customization.
- It doesn’t care about code logic but only about making the code look “right.”
- It saves developers time by taking away the decision-making process about formatting.
What is Ruff?
Ruff is a Python linter and code formatter that focuses on being incredibly fast. It performs static analysis checks (like Pylint) but with a focus on speed and minimal resource usage. Ruff aims to cover a wide range of Python code quality checks, including linting, formatting, and detecting common issues in the codebase.
- Ruff is known for its speed and efficiency, making it suitable for large codebases.
- It integrates some features of Pylint, Flake8, and Black, providing a lightweight alternative to running multiple tools.
Differences Between Pylint, Black, and Ruff

Python linters compared at a glance
| Pylint | Black | Ruff | |
|---|---|---|---|
| Type | Linter (static analysis) | Formatter | Linter and formatter |
| Written in | Python | Python | Rust |
| Speed | Slowest | Fast | Fastest |
| Finds bugs and unused code | Yes, deepest | No | Yes, wide rule set |
| Refactoring and design hints | Yes (R messages) | No | Some (via rules ported from plugins) |
| Auto-fix | No | Formats whole file | Yes (--fix) and formats |
| Configuration | .pylintrc or pyproject.toml | Minimal | pyproject.toml or ruff.toml |
| Main command | pylint file.py | black file.py | ruff check / ruff format |
5. Configuring Pylint
Pylint is highly customizable, allowing developers to enable or disable specific rules, set thresholds for warnings, and tailor checks according to the needs of the project.
Using .pylintrc Configuration File
The .pylintrc file is used to customize Pylint’s behavior for a specific project. You can generate this file using the following command:
pylint --generate-rcfile > .pylintrc
This file contains all the settings that control how Pylint behaves. You can disable specific checks, change the severity of warnings, and customize thresholds for things like maximum line length or cyclomatic complexity.
Customizing Pylint Rules
To disable a specific message, add it to the disable section of your .pylintrc file:
[MESSAGES CONTROL]
disable=C0111, W0611
This would disable the “missing docstring” warning and the “unused import” warning.
Note (2026): the old code C0111 is still accepted as an alias, but symbolic names such as missing-function-docstring and unused-import are easier to read. You can also keep all Pylint, Black-style and Ruff settings together in pyproject.toml.
Updated version (2026): one pyproject.toml for Ruff and Pylint
[tool.ruff]
line-length = 88
target-version = "py312"
[tool.ruff.lint]
select = ["E", "F", "W", "I", "B", "UP"]
[tool.ruff.format]
quote-style = "double"
[tool.pylint.main]
disable = ["missing-module-docstring", "too-few-public-methods"]
[tool.pylint.format]
max-line-length = 88
Suppressing Specific Messages
In some cases, you might want to disable Pylint checks for a specific line of code. You can do this using an inline comment:
my_var = 5 # pylint: disable=unused-variable
This suppresses the unused-variable message for that line only.
6. Pylint in Continuous Integration
Integrating Pylint into your Continuous Integration (CI) pipeline ensures that code quality is maintained throughout the development lifecycle. By running Pylint automatically on every push or pull request, you can catch issues early and prevent them from being merged into the codebase.
Setting Up Pylint with CI Tools
Most CI tools, like GitHub Actions, Travis CI, and Jenkins, support running Python scripts and linters as part of the build process. Below is an example GitHub Actions workflow that runs Pylint on every push:
name: Pylint Check
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip install pylint
- name: Run Pylint
run: pylint my_python_file.py
Updated version (2026): the @v2 actions above are outdated. This workflow uses current action versions and runs Ruff (lint and format check) before Pylint:
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install linters
run: pip install ruff pylint
- name: Ruff lint
run: ruff check .
- name: Ruff format check
run: ruff format --check .
- name: Pylint
run: pylint my_python_file.py
7. Code Formatting: Pylint vs Black
Pylint performs some code style checks, but it doesn’t enforce consistent code formatting. Black steps in as a powerful tool for this purpose, ensuring that your code follows strict style rules. Combining the two tools results in better code readability and maintainability.
Black’s Role in Code Formatting
Black’s primary job is to format Python code. When you run Black, it automatically re-formats your code so that it adheres to a consistent style.
To use Black, install it via pip:
pip install black
Then, you can format your Python file like this:
black my_python_file.py
Black ensures that the code is formatted in a uniform way, without any need for manual intervention.
Combining Pylint and Black for Better Code Quality
By using Pylint and Black together, you get the best of both worlds: Black ensures your code looks clean and consistent, while Pylint checks for deeper issues, such as code smells and logic errors.
black my_python_file.py
pylint my_python_file.py
Running Black first means Pylint will not raise most formatting-related warnings such as whitespace and line wrapping (naming and docstring checks still apply). This workflow keeps your codebase clean and error-free.
How Black Differs from Pylint’s Code Style Suggestions
While Pylint has its own set of style guidelines (mostly based on PEP8), Black enforces a stricter set of rules, focusing entirely on formatting. Black has very few options (mainly line length and target Python versions), so developers cannot adjust its style rules. This can sometimes conflict with Pylint’s checks, but by running Black first, you can ensure that your code is consistently formatted before Pylint checks it.
8. Code Quality and Performance: Pylint vs Ruff
Ruff is designed to be extremely fast, making it ideal for large codebases. While Pylint offers more in-depth analysis, Ruff’s strength lies in its speed and its ability to combine multiple tools into one.
Ruff’s Speed and Performance Optimization
Ruff is highly optimized for performance and can run many checks simultaneously. It combines the functionality of several linters (such as Flake8, isort and many Flake8 plugins) and formatters (like Black), resulting in much faster analysis than Pylint.
To install and use Ruff:
pip install ruff
Run Ruff on your Python file:
ruff my_python_file.py
Updated version (2026): current Ruff releases need a subcommand, so ruff my_python_file.py now fails with “unrecognized subcommand”. Use:
ruff check my_python_file.py # lint
ruff check --fix my_python_file.py # lint and auto-fix safe issues
ruff format my_python_file.py # format (Black-compatible style)
Ruff performs both linting (ruff check) and formatting (ruff format) tasks at a speed unmatched by most other tools.
How Ruff Enhances Static Analysis in Large Projects
In large Python projects with thousands of lines of code, speed matters. Ruff’s ability to run static analysis on large codebases in a fraction of the time Pylint would take makes it a great choice for continuous integration pipelines where time is critical.
Using Ruff with Pylint for Maximum Coverage
While Ruff offers speed, Pylint’s depth of analysis is often necessary for catching more complex issues. By combining Ruff with Pylint, you can achieve both speed and thorough code analysis. First, run Ruff for fast, initial checks, and then use Pylint for deeper analysis:
ruff my_python_file.py
pylint my_python_file.py
ruff check --fix .
ruff format .
pylint my_python_file.py
9. Refactoring Code with Pylint
Pylint excels at suggesting code refactors, which helps developers maintain a clean and efficient codebase over time.
How Pylint Suggests Code Refactors
Pylint’s R (Refactor) messages suggest ways to improve the structure and efficiency of your code. For example:
- R0913 (too-many-arguments): This message suggests refactoring functions that accept too many parameters.
- R0903 (too-few-public-methods): Indicates that a class is underutilized and may not need to be a class.
By following these suggestions, developers can reduce complexity and improve code readability.
Pylint’s Role in Maintaining a Clean Codebase
Refactoring with Pylint keeps the code clean and maintainable, ensuring that it doesn’t become bloated or unnecessarily complex. By regularly addressing Pylint’s suggestions, developers can avoid technical debt and make their code easier to maintain in the long run.
10. Writing Custom Pylint Plugins
For projects with specific needs, Pylint’s extensibility allows developers to write custom plugins that enforce project-specific rules.
When to Extend Pylint with Custom Plugins
Custom plugins are useful when a project requires checks that are not provided by Pylint out-of-the-box. For example, if a project has unique naming conventions or requires specific function signatures, a custom plugin can be written to enforce these rules.
Step-by-Step Guide to Writing a Pylint Plugin
Here’s a simple guide to writing a custom Pylint plugin:
1. Create a new Python file for the plugin.
2. Import necessary Pylint classes:
from pylint.checkers import BaseChecker
from pylint.interfaces import IAstroidChecker
3. Define a new checker class that inherits from BaseChecker:
class CustomChecker(BaseChecker):
__implements__ = IAstroidChecker
name = 'custom-checker'
msgs = {
'C9001': ('Custom message here', 'custom-check', 'Description of custom check.')
}
def visit_functiondef(self, node):
# Implement custom logic for checking functions here
pass
4. Register the plugin:
def register(linter):
linter.register_checker(CustomChecker(linter))
Now you can run Pylint with this custom plugin and enforce your own project rules.
Updated version (2026): the plugin above was written for Pylint 2.x. Pylint 3.0 removed the IAstroidChecker interface and the __implements__ attribute, so that import now raises an ImportError. On current Pylint you simply subclass BaseChecker. This version was tested with Pylint 4.1 and flags function names shorter than three characters:
from pylint.checkers import BaseChecker
class CustomChecker(BaseChecker):
name = 'custom-checker'
msgs = {
'C9001': ('Function name %s is too short', 'short-function-name', 'Function names should be at least 3 characters.')
}
def visit_functiondef(self, node):
if len(node.name) < 3:
self.add_message('short-function-name', node=node, args=(node.name,))
def register(linter):
linter.register_checker(CustomChecker(linter))
PYTHONPATH=. pylint --load-plugins=plug my_python_file.py
11. Advanced Techniques for Managing Pylint in Large Projects
In large projects with multiple developers, managing Pylint checks can become challenging. Here are some techniques for managing Pylint in such environments.
Handling Legacy Code with Pylint
When integrating Pylint into a legacy codebase, you may encounter a large number of warnings and errors. One strategy is to focus on new code while gradually refactoring old code.
- Use the .pylintrc file to disable certain warnings in legacy files.
- Only enforce Pylint on new files or modified code to prevent overwhelming developers with warnings from legacy code.
Strategies for Enforcing Pylint Rules in Multi-Developer Teams
In teams, it’s essential to ensure consistency in how Pylint is used. Here are some strategies:
- Create a shared .pylintrc file and enforce it across the team.
- Use Git hooks or pre-commit hooks to automatically run Pylint before code is pushed.
- Run Pylint in CI to ensure that all code in the main branch adheres to quality standards.
12. Integrating Pylint with Popular Python IDEs
Most modern Python IDEs support Pylint, allowing developers to receive real-time feedback while coding.
Pylint in VS Code
To use Pylint in VS Code:
- Install the Pylint extension from the VS Code marketplace.
- Configure the extension to run Pylint every time you save a file.
Pylint in PyCharm
In PyCharm, you can configure Pylint as an external tool:
- Go to File > Settings > Tools > External Tools.
- Add Pylint as a tool and configure the path to Pylint in the settings.
This allows you to run Pylint directly from the IDE.
Ruff also has an official VS Code extension that lints and formats on save, so a common 2026 setup is the Ruff extension for instant feedback plus Pylint in CI for deeper checks. If you are setting up a fresh environment, see how to install packages in a virtual environment and use them in VS Code and uv, the fast Python package manager.
13. Best Practices for Using Pylint, Black, and Ruff Together
By using Pylint, Black, and Ruff together, you can achieve a powerful, all-encompassing code quality workflow. Here’s a suggested workflow:
- Run Black: Format your code first to ensure it adheres to consistent style rules.
- Run Ruff: Use Ruff for fast linting and static analysis.
- Run Pylint: Use Pylint to catch deeper issues and code smells.
By following this order, you can prevent conflicts between tools and ensure that your code is both clean and error-free.
Since Ruff’s formatter is designed as a drop-in replacement for Black, many teams now replace step 1 with ruff format and steps 1 and 2 become a single tool. Keep Black only if your project already depends on it.
Worked example: Ruff, Black and Pylint on the same file
To see how the three Python linters differ, here is a small trading helper with typical problems:
import os, sys
def signal(close,ema):
if close>ema: return "BUY"
else:
return "SELL"
1. Ruff lint (ruff check strat.py) finds the unused and badly formatted imports and the one-line if statement in milliseconds:
strat.py:1:1: E401 [*] Multiple imports on one line
strat.py:1:1: I001 [*] Import block is un-sorted or un-formatted
strat.py:1:8: F401 [*] `os` imported but unused
strat.py:1:12: F401 [*] `sys` imported but unused
strat.py:3:17: E701 Multiple statements on one line (colon)
Found 5 errors.
[*] 4 fixable with `--fix`.
2. Ruff fix and format (ruff check --fix then ruff format) removes the unused imports and reformats the code. Black produces the same layout:
def signal(close, ema):
if close > ema:
return "BUY"
else:
return "SELL"
3. Pylint then reports the things a formatter cannot fix: a missing docstring and an unnecessary else after return:
strat.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
strat.py:2:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
Outputs were produced with Ruff 0.17, Black 26.10 and Pylint 4.1 using the pyproject.toml shown earlier. The exact rule codes you see depend on which Ruff rule sets you select.
14. Common Pitfalls When Using Pylint and How to Avoid Them
While Pylint is a powerful tool, there are some common issues that developers face:
- Overwhelming Warnings: In large projects, Pylint may generate too many warnings. Use .pylintrc to disable or lower the severity of less important checks.
- False Positives: Sometimes Pylint will raise warnings for code that is correct. Use inline comments to disable specific warnings.
- Slow Performance: For large codebases, Pylint can be slow. Use Ruff for faster linting and run Pylint less frequently.
15. Achieving Clean, Maintainable Python Code with Pylint, Black, and Ruff
By combining Pylint with Black and Ruff, Python developers can achieve a high level of code quality and consistency. Pylint provides deep analysis and error checking, while Black ensures consistent formatting, and Ruff offers fast, lightweight linting. Together, these tools form a powerful trio for improving Python codebases.
If you write trading code with AI assistants, running Ruff and Pylint on generated code is a cheap safety net. See algo trading development with AWS Bedrock and Cline in VS Code and Jupyter AI for traders for those workflows.
Frequently Asked Questions
Which is the best Python linter?
For most projects, Ruff: it is the fastest and covers Flake8, isort and many plugins. Add Pylint if you want deeper analysis and refactoring hints. Black (or ruff format) handles formatting.
Is Ruff better than Pylint?
Ruff is much faster and has a larger rule set, but Pylint still performs some deeper inference-based checks. Many teams run Ruff on every save and Pylint in CI.
Ruff vs Black: do I need both?
Usually not. Ruff’s formatter follows Black’s style, so ruff format can replace Black. Keep Black only for existing projects that already use it.
Is Black a linter?
No. Black is a formatter. It rewrites layout and does not report bugs or unused code.
How do I disable a Pylint warning for one line?
Add an inline comment such as # pylint: disable=unused-variable at the end of the line.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

