# Ruff — Ultra-Fast Python Linter & Formatter > Python linter and formatter written in Rust. 10-100x faster than Flake8 and Black. Replaces Flake8, isort, pyupgrade, and more with a single tool. 40,000+ GitHub stars. ## Install Save as a script file and run: ## Quick Use ```bash # Install pip install ruff # Lint your project ruff check . # Auto-fix issues ruff check --fix . # Format code (replaces Black) ruff format . ``` Add to `pyproject.toml`: ```toml [tool.ruff] line-length = 88 target-version = "py312" [tool.ruff.lint] select = ["E", "F", "I", "N", "UP", "B", "SIM"] ``` --- ## Intro Ruff is an extremely fast Python linter and code formatter written in Rust with 40,000+ GitHub stars. It replaces Flake8, Black, isort, pyupgrade, pydocstyle, and autoflake with a single tool that runs 10-100x faster. A full lint pass on CPython (600K+ lines) completes in under 0.3 seconds. Best for Python developers and AI agents who need instant feedback on code quality. Works with: any Python project, CI/CD pipelines, pre-commit hooks. Setup time: under 1 minute. --- ## What Ruff Replaces | Old Tool | Ruff Equivalent | Speed Improvement | |----------|----------------|-------------------| | Flake8 | `ruff check` | 25-100x faster | | Black | `ruff format` | 10-30x faster | | isort | `ruff check --select I` | 50x faster | | pyupgrade | `ruff check --select UP` | 100x faster | | pydocstyle | `ruff check --select D` | 50x faster | | autoflake | `ruff check --select F` | 80x faster | ### 800+ Lint Rules Ruff implements rules from 50+ Flake8 plugins: ```toml [tool.ruff.lint] select = [ "E", # pycodestyle errors "F", # pyflakes "I", # isort "N", # pep8-naming "UP", # pyupgrade "B", # bugbear "SIM", # simplify "TCH", # type-checking imports "RUF", # ruff-specific rules ] ``` ### Auto-Fix Most issues can be fixed automatically: ```bash ruff check --fix . # Fixed 42 issues: # 12 × F401 (unused imports removed) # 8 × I001 (imports sorted) # 6 × UP035 (deprecated typing replaced) # ... ``` ### Editor Integration - VS Code: `charliermarsh.ruff` extension - Neovim: built-in LSP support - Pre-commit: `ruff-pre-commit` hook ### CI Configuration ```yaml # .github/workflows/lint.yml - name: Ruff run: | pip install ruff ruff check . ruff format --check . ``` ### Key Stats - 40,000+ GitHub stars - 800+ lint rules from 50+ plugins - 10-100x faster than alternatives - Written in Rust by Astral - Used by FastAPI, Pandas, Airflow ### FAQ **Q: What is Ruff?** A: Ruff is a Python linter and formatter written in Rust that replaces Flake8, Black, isort, and several other tools with a single, 10-100x faster alternative. **Q: Is Ruff free?** A: Yes, fully open-source under MIT license. **Q: Is Ruff compatible with Black formatting?** A: Yes, `ruff format` is designed as a drop-in replacement for Black with near-identical output. --- ## Source & Thanks > Created by [Astral](https://github.com/astral-sh). Licensed under MIT. > > [ruff](https://github.com/astral-sh/ruff) — ⭐ 40,000+ Thanks to the Astral team for making Python linting instant. --- ## 快速使用 ```bash pip install ruff ruff check . # 代码检查 ruff check --fix . # 自动修复 ruff format . # 代码格式化 ``` --- ## 简介 Ruff 是一个用 Rust 编写的超快 Python 代码检查和格式化工具,GitHub 40,000+ stars。单一工具替代 Flake8、Black、isort 等 6 个工具,速度快 10-100 倍。CPython 60 万行代码的完整检查在 0.3 秒内完成。适合需要即时代码质量反馈的 Python 开发者和 AI Agent。 --- ## 来源与感谢 > Created by [Astral](https://github.com/astral-sh). Licensed under MIT. > > [ruff](https://github.com/astral-sh/ruff) — ⭐ 40,000+ --- Source: https://tokrepo.com/en/workflows/456bad98-6764-4441-8f63-457b7c3ed3dd Author: Script Depot