Home Knowledge Base Ruff

Ruff is an extremely fast Python linter and formatter written in Rust — running 10-100× faster than existing tools while supporting 700+ lint rules from Flake8, pylint, isort, and more, making it the modern all-in-one solution for Python code quality.

What Is Ruff?

Why Ruff Matters

Performance

Speed Comparison:

Real-World Benchmarks:

Key Features

Comprehensive Rules:

Auto-fixing:

# Fix issues automatically
ruff check --fix .

# Show what would be fixed
ruff check --fix --diff .

Built-in Formatter:

# Format code (Black-compatible)
ruff format .

Quick Start

# Install
pip install ruff

# Lint current directory
ruff check .

# Auto-fix issues
ruff check --fix .

# Format code
ruff format .

# Watch mode
ruff check --watch .

Configuration

# pyproject.toml
[tool.ruff]
line-length = 88
target-version = "py310"

# Enable rules
select = [
    "E",   # pycodestyle errors
    "W",   # pycodestyle warnings
    "F",   # Pyflakes
    "I",   # isort
    "N",   # pep8-naming
    "UP",  # pyupgrade
    "B",   # flake8-bugbear
]

# Ignore specific rules
ignore = ["E501"]  # Line too long

# Exclude directories
exclude = [".git", "__pycache__", "venv", "migrations"]

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]  # Ignore unused imports

Integration

VS Code:

{
    "ruff.enable": true,
    "ruff.organizeImports": true,
    "editor.formatOnSave": true,
    "[python]": {
        "editor.defaultFormatter": "charliermarsh.ruff"
    }
}

Pre-commit:

repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.1.9
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

GitHub Actions:

- name: Lint with Ruff
  run: |
    pip install ruff
    ruff check .
    ruff format --check .

Migration

From Flake8 + isort + Black:

# Old workflow (slow)
isort . && black . && flake8 .

# New workflow (fast)
ruff check --fix . && ruff format .

Comparison

vs Flake8: 100× faster, more rules, built-in auto-fix. vs pylint: 10-100× faster, simpler config, fewer false positives. vs Black: Ruff format is Black-compatible, comparable speed. vs isort: Built-in import sorting, much faster.

Best Practices

Adoption Strategy

Week 1: Install, run ruff check ., configure basic rules. Week 2: Run ruff check --fix ., review changes, add to pre-commit. Week 3: Add to CI/CD, enforce in pull requests. Week 4: Enable more rule categories, document in CONTRIBUTING.md.

Why So Fast?

Ruff is revolutionizing Python linting — replacing multiple slow tools with one blazingly fast solution that saves time in development and CI/CD, making code quality checks instant rather than a bottleneck.

rufflintfast

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.