CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-refurb

A tool for refurbishing and modernizing Python codebases

Pending
Overview
Eval results
Files

cli.mddocs/

Command Line Interface

Refurb's primary interface for code analysis with comprehensive options for configuration, error filtering, output formatting, and integration with development workflows.

Capabilities

Main Entry Points

Core functions that provide the CLI functionality and entry points for refurb.

def main(args: list[str]) -> int:
    """
    Main CLI entry point that processes command line arguments and executes refurb analysis.
    
    Parameters:
    - args: List of command line arguments
    
    Returns:
    Exit code (0 for success, 1 for errors or findings)
    """

def usage() -> None:
    """
    Display comprehensive help information including all command line options,
    subcommands, and usage examples.
    """

def version() -> str:
    """
    Get version information for both refurb and the underlying mypy dependency.
    
    Returns:
    Formatted version string containing refurb and mypy versions
    """

def explain(settings: Settings) -> str:
    """
    Generate detailed explanation for a specific error code.
    
    Parameters:
    - settings: Settings object with explain field set to target ErrorCode
    
    Returns:
    Formatted explanation string with error description, examples, and filename
    """

Command Line Options

Refurb supports extensive command line configuration:

Analysis Control:

  • --ignore err: Ignore specific error codes (can be repeated)
  • --enable err: Enable checks disabled by default (can be repeated)
  • --disable err: Disable checks enabled by default (can be repeated)
  • --enable-all: Enable all available checks
  • --disable-all: Disable all checks by default
  • --load module: Add module to check search paths (can be repeated)

Output Formatting:

  • --format format: Output format ("text" or "github")
  • --sort sort: Sort order ("filename" or "error")
  • --quiet: Suppress default explanation suggestions
  • --verbose: Increase verbosity
  • --debug: Print AST representation of analyzed files

Configuration:

  • --config-file file: Load specified config file instead of default
  • --python-version x.y: Target Python version for analysis
  • --timing-stats file: Export timing information as JSON

Information Commands:

  • --help, -h: Display help menu
  • --version: Print version information
  • --explain err: Print explanation for specific error code

Subcommands

# Generate boilerplate code for new checks
refurb gen

Usage Patterns

# Basic analysis
refurb src/

# Multiple files and directories  
refurb file1.py src/ tests/

# Ignore specific errors
refurb --ignore FURB105,FURB123 src/

# Enable additional checks
refurb --enable FURB999 --enable-all src/

# Custom formatting for CI
refurb --format github --quiet src/

# Load custom checks
refurb --load ./my_checks --load ./more_checks src/

# Target specific Python version
refurb --python-version 3.11 src/

# Pass additional arguments to mypy
refurb src/ -- --strict --disallow-untyped-defs

# Get detailed error explanation
refurb --explain FURB105

# Performance analysis
refurb --timing-stats timing.json src/

Integration Examples

# Pre-commit hook
refurb --format github --quiet

# GitHub Actions
refurb --format github src/

# CI pipeline with custom config
refurb --config-file .refurb.toml --format github src/

Install with Tessl CLI

npx tessl i tessl/pypi-refurb

docs

analysis.md

ast-utilities.md

cli.md

configuration.md

errors.md

index.md

plugins.md

tile.json