Scripts2026年3月29日·1 分钟阅读

Ruff — Ultra-Fast Python Linter & Formatter

Rust-powered Python linter and formatter. 10-100x faster than Flake8 + Black combined. 800+ lint rules, auto-fix, import sorting, and format-on-save.

TO
TokRepo精选 · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install ruff

# Lint
ruff check .

# Format
ruff format .

# Fix auto-fixable issues
ruff check --fix .

介绍

Ruff is an extremely fast Python linter and code formatter written in Rust. It replaces Flake8, Black, isort, pycodestyle, pydocstyle, and dozens more tools — in a single binary that runs 10-100x faster.

Best for: Any Python project — linting, formatting, import sorting Works with: VS Code, PyCharm, Neovim, CI/CD, pre-commit hooks


Key Features

  • 800+ rules from Flake8, pycodestyle, pydocstyle, isort, and more
  • Auto-fix for 400+ rule violations
  • Formatter — Black-compatible, drop-in replacement
  • Import sorting — isort-compatible
  • 10-100x faster than existing tools (Rust-powered)
  • Zero config — works out of the box, customizable via pyproject.toml

Configuration

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

[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP"]

🙏

来源与感谢

Created by Astral. Licensed under MIT. astral-sh/ruff — 35K+ GitHub stars

相关资产