Convert Figma logo to code with AI

pylint-dev logopylint

It's not just a linter that annoys you!

5,237
1,116
5,237
962

Top Related Projects

3,391

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.

38,528

The uncompromising Python code formatter

Simple Python style checker in one Python file

docstring style checker

13,726

A formatter for Python files

30,822

An extremely fast Python linter and code formatter, written in Rust.

Quick Overview

Pylint is a widely-used static code analysis tool for Python. It checks for coding standards, errors, and potential bugs in Python code, helping developers maintain clean and consistent codebases. Pylint also provides suggestions for code improvement and can be customized to fit specific project needs.

Pros

  • Comprehensive analysis: Checks for a wide range of issues, including coding style, errors, and potential bugs
  • Highly configurable: Can be customized to fit specific project requirements and coding standards
  • Integration support: Easily integrates with various IDEs, text editors, and CI/CD pipelines
  • Detailed reports: Provides in-depth analysis reports with clear explanations and suggestions for improvement

Cons

  • Learning curve: Can be overwhelming for beginners due to its extensive set of rules and options
  • False positives: May sometimes report issues that are not actually problems, requiring manual review
  • Performance impact: Can be slow when analyzing large codebases or complex projects
  • Strict defaults: Default settings may be too strict for some projects, requiring initial configuration

Code Examples

  1. Basic usage:
# Run Pylint on a Python file
pylint my_file.py
  1. Customizing Pylint behavior:
# Use a custom configuration file
pylint --rcfile=my_pylintrc my_file.py
  1. Ignoring specific warnings:
# Disable specific warnings
pylint --disable=C0111,W0611 my_file.py

Getting Started

  1. Install Pylint:
pip install pylint
  1. Run Pylint on a Python file:
pylint your_file.py
  1. Create a custom configuration file (optional):
pylint --generate-rcfile > .pylintrc
  1. Modify the .pylintrc file to customize Pylint's behavior for your project.

  2. Run Pylint with the custom configuration:

pylint --rcfile=.pylintrc your_file.py

Competitor Comparisons

3,391

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.

Pros of flake8

  • Faster execution time, especially for large codebases
  • Modular architecture allows for easy plugin integration
  • Lightweight and focuses on style and syntax errors

Cons of flake8

  • Less comprehensive error detection compared to Pylint
  • Limited ability to detect logical errors or complex code issues
  • Fewer configuration options for customizing checks

Code Comparison

Pylint example:

def example_function(param1, param2):
    """This is a docstring."""
    result = param1 + param2
    return result

flake8 example:

def example_function(param1, param2):
    result = param1 + param2
    return result

In this comparison, Pylint would likely raise a warning about the missing docstring in the flake8 example, while flake8 would not detect this issue by default. However, flake8 would still catch basic style and syntax errors in both cases.

Both tools are valuable for maintaining code quality, with Pylint offering more comprehensive checks at the cost of speed, while flake8 provides faster, more focused analysis. The choice between them often depends on project requirements and personal preferences.

38,528

The uncompromising Python code formatter

Pros of Black

  • Opinionated and consistent formatting with minimal configuration
  • Faster execution time for formatting large codebases
  • Integrates well with popular IDEs and CI/CD pipelines

Cons of Black

  • Less flexibility in code style customization
  • May produce unexpected formatting in some edge cases
  • Limited to formatting; doesn't perform linting or error checking

Code Comparison

Black formatting example:

def long_function_name(
    var_one, var_two, var_three, var_four
):
    print(f"{var_one} {var_two} {var_three} {var_four}")

Pylint-compatible formatting example:

def long_function_name(var_one,
                       var_two,
                       var_three,
                       var_four):
    print(f"{var_one} {var_two} {var_three} {var_four}")

Black focuses solely on code formatting, enforcing a consistent style across projects. It's fast and requires minimal configuration, making it popular for teams wanting a standardized appearance. However, it offers less flexibility in customization compared to Pylint.

Pylint, on the other hand, is a comprehensive linting tool that checks for errors, enforces coding standards, and can be highly customized. It provides more detailed feedback on code quality but may require more setup and configuration than Black.

While Black is excellent for maintaining consistent formatting, Pylint offers broader code quality checks and customization options, making them complementary tools in many Python development workflows.

Simple Python style checker in one Python file

Pros of pycodestyle

  • Lightweight and fast, focusing solely on PEP 8 style checking
  • Easy to integrate into CI/CD pipelines due to its simplicity
  • Provides clear, concise error messages with line numbers

Cons of pycodestyle

  • Limited scope compared to Pylint's comprehensive analysis
  • Lacks advanced features like code smell detection and refactoring suggestions
  • No customizable configuration options for specific project needs

Code Comparison

pycodestyle:

import pycodestyle

style_guide = pycodestyle.StyleGuide()
result = style_guide.check_files(['example.py'])
print(result.total_errors)

Pylint:

from pylint import epylint as lint

(pylint_stdout, pylint_stderr) = lint.py_run('example.py', return_std=True)
print(pylint_stdout.getvalue())

pycodestyle focuses on PEP 8 style checking, providing a straightforward approach to ensuring code adheres to Python's style guide. It's fast and easy to use but lacks the depth of analysis offered by Pylint.

Pylint, on the other hand, offers a more comprehensive code analysis, including error detection, coding standards enforcement, and refactoring help. It's highly configurable but can be more complex to set up and use compared to pycodestyle.

Choose pycodestyle for quick style checks or Pylint for in-depth code analysis and customization options.

docstring style checker

Pros of pydocstyle

  • Focused specifically on docstring style checking
  • Lightweight and fast execution
  • Easy integration with other tools and CI pipelines

Cons of pydocstyle

  • Limited scope compared to Pylint's broader code analysis
  • Fewer configuration options and customization features
  • Less frequent updates and smaller community

Code Comparison

pydocstyle:

def example_function():
    """This is a docstring.

    It follows the PEP 257 conventions.
    """
    pass

Pylint:

def example_function():
    """This is a docstring.

    It follows the PEP 257 conventions.
    """
    # Pylint can check both docstrings and code quality
    unused_variable = 10  # This would trigger a Pylint warning
    pass

pydocstyle focuses solely on docstring conventions, while Pylint provides a more comprehensive code analysis, including docstring checks, code style, and potential errors. pydocstyle is ideal for projects that require strict docstring adherence, while Pylint offers a broader range of code quality checks at the cost of increased complexity and runtime.

13,726

A formatter for Python files

Pros of YAPF

  • Focuses solely on code formatting, providing a more specialized tool
  • Offers a high degree of customization through configuration files
  • Can reformat entire codebases with consistent style

Cons of YAPF

  • Limited to formatting; doesn't perform code analysis or error detection
  • May require more manual configuration to achieve desired formatting
  • Less comprehensive in terms of overall code quality improvement

Code Comparison

Pylint (linting example):

def example_function(unused_param):
    x = 10
    return x + 1

Pylint output:

W0613: Unused argument 'unused_param' (unused-argument)

YAPF (formatting example):

def long_function_name(
    var_one, var_two, var_three, var_four):
    print(var_one)

YAPF output:

def long_function_name(var_one, var_two, var_three, var_four):
    print(var_one)

Summary

While Pylint focuses on comprehensive code analysis, error detection, and style checking, YAPF specializes in code formatting. Pylint offers broader code quality improvements, whereas YAPF ensures consistent code style across projects. The choice between them depends on whether you prioritize code analysis or formatting automation.

30,822

An extremely fast Python linter and code formatter, written in Rust.

Pros of Ruff

  • Significantly faster execution due to being written in Rust
  • Combines functionality of multiple tools (e.g., isort, pycodestyle) into one
  • Provides automatic code fixes for many issues

Cons of Ruff

  • Newer project with potentially less stability and community support
  • May not cover all the checks and features provided by Pylint
  • Limited customization options compared to Pylint's extensive configuration

Code Comparison

Pylint configuration:

# .pylintrc
[MASTER]
ignore=CVS
ignore-patterns=
persistent=yes
load-plugins=
jobs=1

Ruff configuration:

# pyproject.toml
[tool.ruff]
select = ["E", "F", "I"]
ignore = ["E501"]
line-length = 88

Both tools aim to improve code quality, but Ruff focuses on speed and simplicity, while Pylint offers more comprehensive analysis and customization. Ruff is gaining popularity for its performance, while Pylint remains a trusted choice for its maturity and extensive feature set.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Pylint_

.. _Pylint: https://pylint.readthedocs.io/

.. This is used inside the doc to recover the start of the introduction

.. image:: https://github.com/pylint-dev/pylint/actions/workflows/tests.yaml/badge.svg?branch=main :target: https://github.com/pylint-dev/pylint/actions

.. image:: https://codecov.io/gh/pylint-dev/pylint/branch/main/graph/badge.svg?token=ZETEzayrfk :target: https://codecov.io/gh/pylint-dev/pylint

.. image:: https://img.shields.io/pypi/v/pylint.svg :alt: PyPI Package version :target: https://pypi.python.org/pypi/pylint

.. image:: https://readthedocs.org/projects/pylint/badge/?version=latest :target: https://pylint.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black

.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen :target: https://github.com/pylint-dev/pylint

.. image:: https://results.pre-commit.ci/badge/github/pylint-dev/pylint/main.svg :target: https://results.pre-commit.ci/latest/github/pylint-dev/pylint/main :alt: pre-commit.ci status

.. image:: https://bestpractices.coreinfrastructure.org/projects/6328/badge :target: https://bestpractices.coreinfrastructure.org/projects/6328 :alt: CII Best Practices

.. image:: https://img.shields.io/ossf-scorecard/github.com/PyCQA/pylint?label=openssf%20scorecard&style=flat :target: https://api.securityscorecards.dev/projects/github.com/PyCQA/pylint :alt: OpenSSF Scorecard

.. image:: https://img.shields.io/discord/825463413634891776.svg :target: https://discord.gg/qYxpadCgkx :alt: Discord

What is Pylint?

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

.. _static code analyser: https://en.wikipedia.org/wiki/Static_code_analysis

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.

.. _code smells: https://martinfowler.com/bliki/CodeSmell.html

Install

.. This is used inside the doc to recover the start of the short text for installation

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 <https://pyenchant.github.io/pyenchant/install.html#installing-the-enchant-c-library>_):

.. code-block:: sh

pip install pylint[spelling]

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

.. _in the documentation: https://pylint.readthedocs.io/en/latest/user_guide/installation/index.html

.. This is used inside the doc to recover the end of the short text for installation

What differentiates Pylint?

Pylint is not trusting your typing and is inferring the actual values 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

.. _Realist pylint user: https://github.com/charliermarsh/ruff/issues/970#issuecomment-1381067064

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`_.

.. _plugins: https://pylint.readthedocs.io/en/latest/development_guide/how_tos/plugins.html#plugins .. _pylint-pydantic: https://pypi.org/project/pylint-pydantic .. _pylint-django: https://github.com/pylint-dev/pylint-django .. _pylint-sonarjson: https://github.com/cnescatlab/pylint-sonarjson-catlab

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).

.. _ruff: https://github.com/astral-sh/ruff .. _flake8: https://github.com/PyCQA/flake8 .. _bandit: https://github.com/PyCQA/bandit .. _mypy: https://github.com/python/mypy .. _pyright: https://github.com/microsoft/pyright .. _pyre: https://github.com/facebook/pyre-check .. _black: https://github.com/psf/black .. _autoflake: https://github.com/myint/autoflake .. _pyupgrade: https://github.com/asottile/pyupgrade .. _pydocstringformatter: https://github.com/DanielNoord/pydocstringformatter .. _isort: https://pycqa.github.io/isort/

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)

.. _pyreverse: https://pylint.readthedocs.io/en/latest/pyreverse.html .. _symilar: https://pylint.readthedocs.io/en/latest/symilar.html

.. This is used inside the doc to recover the end of the introduction

Contributing

.. This is used inside the doc to recover the start of the short text for contribution

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.

.. _creating issues because you found a bug or want a feature: https://pylint.readthedocs.io/en/latest/contact.html#bug-reports-feedback .. _code of conduct: https://github.com/pylint-dev/pylint/blob/main/CODE_OF_CONDUCT.md .. _the Contributor Guides: https://pylint.readthedocs.io/en/latest/development_guide/contribute.html

.. This is used inside the doc to recover the end of the short text for contribution

Show your usage

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

.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen
    :target: https://github.com/pylint-dev/pylint

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

.. _the badge documentation: https://pylint.readthedocs.io/en/latest/user_guide/installation/badge.html

License

pylint is, with a few exceptions listed below, GPLv2 <https://github.com/pylint-dev/pylint/blob/main/LICENSE>_.

The icon files are licensed under the CC BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0/>_ license:

  • doc/logo.png <https://raw.githubusercontent.com/pylint-dev/pylint/main/doc/logo.png>_
  • doc/logo.svg <https://raw.githubusercontent.com/pylint-dev/pylint/main/doc/logo.svg>_

Support

Please check the contact information_.

.. _the contact information: https://pylint.readthedocs.io/en/latest/contact.html

.. |tideliftlogo| image:: https://raw.githubusercontent.com/pylint-dev/pylint/main/doc/media/Tidelift_Logos_RGB_Tidelift_Shorthand_On-White.png :width: 200 :alt: Tidelift

.. list-table:: :widths: 10 100

    • |tideliftlogo|
    • 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.

.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-pylint?utm_source=pypi-pylint&utm_medium=referral&utm_campaign=readme