or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

built-in-checkers.mdchecker-development.mdconfiguration.mdcore-linting.mdextensions.mdindex.mdmessages.mdpyreverse.mdreporters.mdtest-utilities.md
tile.json

tessl/pypi-pylint

Comprehensive static code analysis tool for Python that performs deep code inspection without executing the program

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pylint@3.3.x

To install, run

npx @tessl/cli install tessl/pypi-pylint@3.3.0

index.mddocs/

Pylint

A comprehensive static code analysis tool for Python that performs deep code inspection without executing the program. Pylint uses advanced inference techniques through its internal astroid representation to understand code semantics beyond simple syntax checking, enabling it to detect complex issues like incorrect API usage even when imports are aliased. The tool enforces coding standards, identifies potential bugs, detects code smells, and provides refactoring suggestions while being highly configurable to adapt to different project requirements.

Package Information

  • Package Name: pylint
  • Language: Python
  • Installation: pip install pylint
  • Documentation: https://pylint.readthedocs.io/

Core Imports

import pylint

For direct API access:

from pylint import run_pylint, run_pyreverse, run_symilar
from pylint.lint import PyLinter
from pylint.checkers import BaseChecker
from pylint.reporters import BaseReporter

Basic Usage

import pylint

# Run pylint on files from Python code
pylint.run_pylint(['mymodule.py', '--output-format=json'])

# Generate UML diagrams
pylint.run_pyreverse(['mypackage/', '--output-format=svg'])

# Find code duplicates
pylint.run_symilar(['mymodule.py', '--min-lines=5'])

# Programmatic linting
from pylint.lint import PyLinter
from pylint.reporters import TextReporter
import io

output = io.StringIO()
reporter = TextReporter(output)
linter = PyLinter()
linter.set_reporter(reporter)
linter.check(['mymodule.py'])
print(output.getvalue())

Architecture

Pylint's modular architecture enables comprehensive static analysis:

  • PyLinter: Core controller that manages the checking process, configuration, and message collection
  • Checker System: 78+ specialized checkers that analyze different aspects of code (variables, imports, format, type checking, etc.)
  • Extension System: 25+ optional extensions for additional specialized checks
  • Reporter System: Multiple output formats (text, JSON, HTML) and custom reporter support
  • Message System: Structured message definitions with confidence levels and categorization
  • Configuration System: Hierarchical configuration from files, command line, and programmatic sources

This design allows users to customize analysis depth, enable/disable specific checks, create custom checkers, and integrate pylint into diverse development workflows.

Capabilities

Core Linting API

Main entry points for running pylint analysis programmatically, including the primary linting functions, configuration management, and result collection.

def run_pylint(argv=None):
    """Run pylint analysis from command line arguments."""

def modify_sys_path():
    """Modify sys.path for execution as Python module."""

class PyLinter:
    """Main linter class controlling the checking process."""
    def check(self, files_or_modules): ...
    def register_checker(self, checker): ...
    def add_message(self, msgid, line, node, args, confidence, col_offset): ...

Core Linting

Checker Development

Framework for creating custom checkers that analyze specific code patterns. Includes base classes, message definition system, and integration with the linter.

class BaseChecker:
    """Abstract base class for all checkers."""
    name: str
    msgs: dict
    options: tuple

class BaseRawFileChecker(BaseChecker):
    """Base class for raw file checkers."""

class BaseTokenChecker(BaseChecker):
    """Base class for token-based checkers."""

Checker Development

Built-in Checkers

Comprehensive set of 78+ built-in checkers covering variables, imports, formatting, type checking, classes, design analysis, and more specialized areas.

# Core checker modules (examples)
import pylint.checkers.variables
import pylint.checkers.imports
import pylint.checkers.format
import pylint.checkers.typecheck
import pylint.checkers.exceptions
import pylint.checkers.classes

Built-in Checkers

Extensions System

Optional extensions providing 33+ additional specialized checkers for code style, complexity analysis, docstring validation, and advanced pattern detection.

# Extension initialization pattern
def initialize(linter):
    """Register extension checker with linter."""

# Available extensions (examples)
import pylint.extensions.code_style
import pylint.extensions.mccabe
import pylint.extensions.docparams

Extensions

Reporters and Output

Flexible reporting system supporting multiple output formats (text, JSON, HTML) and custom reporter development for integration with different tools and workflows.

class BaseReporter:
    """Abstract base for all reporters."""
    def handle_message(self, msg): ...
    def set_output(self, output): ...

class TextReporter(BaseReporter): ...
class JSONReporter(BaseReporter): ...
class MultiReporter(BaseReporter): ...

Reporters

Configuration Management

Hierarchical configuration system that handles command-line arguments, configuration files, and programmatic settings with validation and default values.

def find_default_config_files():
    """Locate default configuration files."""

class ArgumentsManager:
    """Command-line argument management."""

def find_pylintrc():
    """Find pylintrc configuration file."""

Configuration

Message System

Structured message definitions with categories, confidence levels, and detailed location information for precise error reporting and filtering.

class Message:
    """Individual message/warning representation."""
    msg_id: str
    symbol: str
    msg: str
    confidence: str
    line: int
    column: int

class MessageDefinition:
    """Message type definition."""

Messages

Pyreverse (UML Generation)

UML diagram generation tool that analyzes Python code structure and creates class diagrams, package diagrams, and dependency visualizations in multiple formats.

def run_pyreverse(argv=None):
    """Generate UML diagrams from Python code."""

class PackageDiagram: ...
class ClassDiagram: ...
class DotWriter: ...
class PlantUmlWriter: ...

Pyreverse

Test Utilities

Testing framework for developing and validating custom checkers, including test case base classes, message validation, and functional testing support.

class CheckerTestCase:
    """Base class for checker unit tests."""

class UnittestLinter:
    """Test-specific linter implementation."""

def set_config(**kwargs):
    """Set configuration for tests."""

Test Utilities

Type Definitions

# Confidence levels
HIGH: str = "HIGH"
CONTROL_FLOW: str = "CONTROL_FLOW" 
INFERENCE: str = "INFERENCE"
INFERENCE_FAILURE: str = "INFERENCE_FAILURE"
UNDEFINED: str = "UNDEFINED"

# Message types
MSG_TYPES: dict = {
    'I': 'info',
    'C': 'convention', 
    'R': 'refactor',
    'W': 'warning',
    'E': 'error',
    'F': 'fatal'
}

# File extensions
PY_EXTS: tuple = ('.py', '.pyw', '.pyc', '.pyo')

Constants

__version__: str  # Package version
version: str      # Version alias

# Message type mappings
MSG_TYPES_STATUS: dict
PY310_PLUS: bool  # Python 3.10+ version flag
PY311_PLUS: bool  # Python 3.11+ version flag
PY312_PLUS: bool  # Python 3.12+ version flag

Exception Classes

class InvalidMessageError(Exception):
    """Invalid message creation error."""

class UnknownMessageError(Exception):
    """Unregistered message error."""

class DeletedMessageError(Exception):
    """Deleted message encountered error."""

class EmptyReportError(Exception):
    """Empty report generation error."""

class InvalidReporterError(Exception):
    """Invalid reporter configuration error."""