• Stars
    star
    4,246
  • Rank 9,657 (Top 0.2 %)
  • Language
    Python
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

It's not just a linter that annoys you!

image

image

Pypi Package version

Documentation Status

image

image

pre-commit.ci status

CII Best Practices

OpenSSF Scorecard

Discord

What is Pylint?

Pylint is a static code analyser for Python 2 or 3. The latest version supports Python 3.8.0 and above.

Pylint analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored.

Install

For command line use, pylint is installed with:

pip install pylint

Or if you want to also check spelling with enchant (you might need to install the enchant C library):

pip install pylint[spelling]

It can also be integrated in most editors or IDEs. More information can be found in the documentation.

What differentiates Pylint?

Pylint is not trusting your typing and is inferring the actual value of nodes (for a start because there was no typing when pylint started off) using its internal code representation (astroid). If your code is import logging as argparse, Pylint can check and know that argparse.error(...) is in fact a logging call and not an argparse call. This makes pylint slower, but it also lets pylint find more issues if your code is not fully typed.

[inference] is the killer feature that keeps us using [pylint] in our project despite how painfully slow it is. - Realist pylint user, 2022

pylint, not afraid of being a little slower than it already is, is also a lot more thorough than other linters. There are more checks, including some opinionated ones that are deactivated by default but can be enabled using configuration.

How to use pylint

Pylint isn't smarter than you: it may warn you about things that you have conscientiously done or check for some things that you don't care about. During adoption, especially in a legacy project where pylint was never enforced, it's best to start with the --errors-only flag, then disable convention and refactor messages with --disable=C,R and progressively re-evaluate and re-enable messages as your priorities evolve.

Pylint is highly configurable and permits to write plugins in order to add your own checks (for example, for internal libraries or an internal rule). Pylint also has an ecosystem of existing plugins for popular frameworks and third-party libraries.

Note

Pylint supports the Python standard library out of the box. Third-party libraries are not always supported, so a plugin might be needed. A good place to start is PyPI which often returns a plugin by searching for pylint <library>. pylint-pydantic, pylint-django and pylint-sonarjson are examples of such plugins. More information about plugins and how to load them can be found at plugins.

Advised linters alongside pylint

Projects that you might want to use alongside pylint include ruff (really fast, with builtin auto-fix and a large number of checks taken from popular linters, but implemented in rust) or flake8 (a framework to implement your own checks in python using ast directly), mypy, pyright / pylance or pyre (typing checks), bandit (security oriented checks), black and isort (auto-formatting), autoflake (automated removal of unused imports or variables), pyupgrade (automated upgrade to newer python syntax) and pydocstringformatter (automated pep257).

Additional tools included in pylint

Pylint ships with two additional tools:

  • pyreverse (standalone tool that generates package and class diagrams.)
  • symilar (duplicate code finder that is also integrated in pylint)

Contributing

We welcome all forms of contributions such as updates for documentation, new code, checking issues for duplicates or telling us that we can close them, confirming that issues still exist, creating issues because you found a bug or want a feature, etc. Everything is much appreciated!

Please follow the code of conduct and check the Contributor Guides if you want to make a code contribution.

Show your usage

You can place this badge in your README to let others know your project uses pylint.

image

Learn how to add a badge to your documentation in the badge documentation.

License

pylint is, with a few exceptions listed below, GPLv2.

The icon files are licensed under the CC BY-SA 4.0 license:

Support

Please check the contact information.

Tidelift Professional support for pylint is available as part of the Tidelift Subscription. Tidelift gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.

More Repositories

1

isort

A Python utility / library to sort imports.
Python
6,308
star
2

bandit

Bandit is a tool designed to find common security issues in Python code.
Python
5,900
star
3

pycodestyle

Simple Python style checker in one Python file
Python
4,924
star
4

flake8

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
Python
3,068
star
5

pyflakes

A simple program which checks Python source files for errors
Python
1,304
star
6

pydocstyle

docstring style checker
Python
1,105
star
7

flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
Python
1,034
star
8

autoflake

Removes unused imports and unused variables as reported by pyflakes
Python
844
star
9

redbaron

Bottom-up approach to refactoring in python
Python
683
star
10

mccabe

McCabe complexity checker for Python
Python
602
star
11

pylint-django

Pylint plugin for improving code analysis for when using Django
Python
556
star
12

docformatter

Formats docstrings to follow PEP 257
Python
493
star
13

pep8-naming

Naming Convention checker for Python
Python
471
star
14

astroid

A common base representation of python source code for pylint and other projects
Python
425
star
15

modernize

Modernizes Python code for eventual Python 3 migration. Built on top of fissix (a fork of lib2to3)
Python
326
star
16

baron

IDE allow you to refactor code, Baron allows you to write refactoring code.
Python
285
star
17

flake8-import-order

Flake8 plugin that checks import order against various Python Style Guides
Python
276
star
18

eradicate

Removes commented-out code from Python files
Python
195
star
19

doc8

Style checker for sphinx (or other) rst documentation.
Python
158
star
20

flake8-docstrings

Integration of pydocstyle and flake8 for combined linting and reporting
Python
144
star
21

flake8-commas

Flake8 extension for enforcing trailing commas in python
Python
128
star
22

flake8-pyi

A plugin for Flake8 that provides specializations for type hinting stub files
Python
70
star
23

pylint-celery

Pylint plugin for analysing code using Celery
Python
34
star
24

meta

Documentation about how the PyCQA organization works
Python
24
star
25

pylint-plugin-utils

Utilities and helpers for writing Pylint plugins
Python
20
star
26

oeuvre

A repository to collect examples of Python code for testing code-quality tools
Python
11
star
27

flake8-polyfill

Project to make writing plugins across major versions of flake8 easier
Python
11
star
28

flake8-json

JSON formatter for Flake8 output
Python
9
star
29

bandit-action

GitHub Action to run Bandit
Dockerfile
8
star
30

infrastructure

Mirror of PyCQA's infrastructure playbooks
6
star
31

mccabe-console-script

Add a console script for the mccabe complexity checker
Python
4
star