Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

ruff

> 编程语言
Free

An extremely fast Python linter and code formatter, written in Rust.

50.0K stars0 likes2 views
WebsiteGitHub

About

An extremely fast Python linter and code formatter, written in Rust.

Ruff

Docs | Playground

An extremely fast Python linter and code formatter, written in Rust.

Linting the CPython codebase from scratch.

  • ⚡️ 10-100x faster than existing linters (like Flake8) and formatters (like Black)
  • 🐍 Installable via pip
  • 🛠️ pyproject.toml support
  • 🤝 Python 3.14 compatibility
  • ⚖️ Drop-in parity with Flake8, isort, and Black
  • 📦 Built-in caching, to avoid re-analyzing unchanged files
  • 🔧 Fix support, for automatic error correction (e.g., automatically remove unused imports)
  • 📏 Over 900 built-in rules, with native re-implementations of popular Flake8 plugins, like flake8-bugbear
  • ⌨️ First-party editor integrations for VS Code and more
  • 🌎 Monorepo-friendly, with hierarchical and cascading configuration

Ruff aims to be orders of magnitude faster than alternative tools while integrating more functionality behind a single, common interface.

Ruff can be used to replace Flake8 (plus dozens of plugins), Black, isort, pydocstyle, pyupgrade, autoflake, and more, all while executing tens or hundreds of times faster than any individual tool.

Ruff is extremely actively developed and used in major open-source projects like:

  • Apache Airflow
  • Apache Superset
  • FastAPI
  • Hugging Face
  • Pandas
  • SciPy

...and many more.

Ruff is backed by Astral, the creators of uv and ty.

Read the launch post, or the original project announcement.

Testimonials

Sebastián Ramírez, creator of FastAPI:

Ruff is so fast that sometimes I add an intentional bug in the code just to confirm it's actually running and checking the code.

Nick Schrock, founder of Elementl, co-creator of GraphQL:

Why is Ruff a gamechanger? Primarily because it is nearly 1000x faster. Literally. Not a typo. On our largest module (dagster itself, 250k LOC) pylint takes about 2.5 minutes, parallelized across 4 cores on my M1. Running ruff against our entire codebase takes .4 seconds.

Bryan Van de Ven, co-creator of Bokeh, original author of Conda:

Ruff is ~150-200x faster than flake8 on my machine, scanning the whole repo takes ~0.2s instead of ~20s. This is an enormous quality of life improvement for local dev. It's fast enough that I added it as an actual commit hook, which is terrific.

Timothy Crosley, creator of isort:

Just switched my first project to Ruff. Only one downside so far: it's so fast I couldn't believe it was working till I intentionally introduced some errors.

Tim Abbott, lead developer of Zulip (also here):

This is just ridiculously fast... ruff is amazing.

Table of Contents

For more, see the documentation.

  1. Getting Started
  2. Configuration
  3. Rules
  4. Contributing
  5. Support
  6. Acknowledgements
  7. Who's Using Ruff?
  8. License

Getting Started

For more, see the documentation.

Installation

Ruff is available as ruff on PyPI.

Invoke Ruff directly with uvx:

bash
uvx [email protected] check   # Lint all files in the current directory.
uvx [email protected] format  # Format all files in the current directory.

Or install Ruff with uv (recommended), pip, or pipx:

bash
# With uv.
uv tool install ruff@latest  # Install Ruff globally.
uv add --dev ruff            # Or add Ruff to your project.

# With pip.
pip install ruff

# With pipx.
pipx install ruff

Starting with version 0.5.0, Ruff can be installed with our standalone installers:

bash
# On macOS and Linux.
curl -LsSf https://astral.sh/ruff/install.sh | sh

# On Windows.
powershell -c "irm https://astral.sh/ruff/install.ps1 | iex"

# For a specific version.
curl -LsSf https://astral.sh/ruff/0.16.6/install.sh | sh
powershell -c "irm https://astral.sh/ruff/0.16.6/install.ps1 | iex"

You can also install Ruff via Homebrew, Conda, and with a variety of other package managers.

Usage

To run Ruff as a linter, try any of the following:

bash
ruff check                          # Lint all files in the current directory (and any subdirectories).
ruff check path/to/code/            # Lint all files in `/path/to/code` (and any subdirectories).
ruff check path/to/code/*.py        # Lint all `.py` files in `/path/to/code`.
ruff check path/to/code/to/file.py  # Lint `file.py`.
ruff check @arguments.txt           # Lint using an input file, treating its contents as newline-delimited command-line arguments.

Or, to run Ruff as a formatter:

bash
ruff format                          # Format all files in the current directory (and any subdirectories).
ruff format path/to/code/            # Format all files in `/path/to/code` (and any subdirectories).
ruff format path/to/code/*.py        # Format all `.py` files in `/path/to/code`.
ruff format path/to/code/to/file.py  # Format `file.py`.
ruff format @arguments.txt           # Format using an input file, treating its contents as newline-delimited command-line arguments.

Ruff can also be used as a pre-commit hook via ruff-pre-commit:

yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
  # Ruff version.
  rev: v0.16.6
  hooks:
    # Run the linter.
    - id: ruff-check
      args: [ --fix ]
    # Run the formatter.
    - id: ruff-format

Ruff can also be used as a VS Code extension or with various other editors.

Ruff can also be used as a GitHub Action via ruff-action:

yaml
name: Ruff
on: [ push, pull_request ]
jobs:
  ruff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/ruff-action@v3

Configuration

Ruff can be configured through a pyproject.toml, ruff.toml, or .ruff.toml file (see: Configuration, or Settings for a complete list of all configuration options).

For the complete list of enabled rules, see Default Rules.

If left unspecified, Ruff's default configuration is equivalent to the following ruff.toml file:

…

Note that, in a pyproject.toml, each section header should be prefixed with tool.ruff. For example, [lint] should be replaced with [tool.ruff.lint].

Some configuration options can be provided via dedicated command-line arguments, such as those related to rule enablement and disablement, file discovery, and logging level:

bash
ruff check --select F401 --select F403 --quiet

The remaining configuration options can be provided through a catch-all --config argument:

bash
ruff check --config "lint.per-file-ignores = {'some_file.py' = ['F841']}"

To opt in to the latest lint rules, formatter style changes, interface updates, and more, enable preview mode by setting preview = true in your configuration file or passing --preview on the command line. Preview mode enables a collection of unstable features that may change prior to stabilization.

See ruff help for more on Ruff's top-level commands, or ruff help check and ruff help format for more on the linting and formatting commands, respectively.

Rules

Ruff supports over 900 lint rules, many of which are inspired by popular tools like Flake8, isort, pyupgrade, and others. Regardless of the rule's origin, Ruff re-implements every rule in Rust as a first-party feature.

By default, Ruff enables rules from the F, E, B, UP, and RUF categories, as well as many more, omitting any stylistic rules that overlap with the use of a formatter, like ruff format or Black.

If you're just getting started with Ruff, the default rule set is a great place to start: it catches a wide variety of common errors (like unused imports) with zero configuration. See Default Rules for the complete list.

Beyond the defaults, Ruff re-implements some of the most popular Flake8 plugins and related code quality tools, including:

  • autoflake
  • eradicate
  • flake8-2020
  • flake8-annotations
  • flake8-async
  • flake8-bandit (#1646)
  • flake8-blind-except
  • flake8-boolean-trap
  • flake8-bugbear
  • flake8-builtins
  • flake8-commas
  • flake8-comprehensions
  • flake8-copyright
  • flake8-datetimez
  • flake8-debugger
  • flake8-django
  • [flake8-docstrings](https://pypi.org/project/flake8-docst

Issues· 2186 open

View all issuesOpen on GitHub
  • #28866

    Support `flake8-lazy` style relative import in `__lazy_modules__`

    ruleneeds-decisionUpdated Sep 29, 2026
  • #10578

    Dependency Dashboard

    internalUpdated Sep 29, 2026
  • #21581

    Formatter should avoid splitting arguments into their own line

    formatterstyleUpdated Sep 28, 2026
  • #28930

    Known Deviations doc incorrect for multiline-strings

    documentationUpdated Sep 28, 2026
  • #28777

    `too-many-positional-arguments`: dataclasses?

    ruleneeds-decisionUpdated Sep 28, 2026
  • #28945

    RUF031 incorrectly-parenthesized-tuple-in-subscript: false negative

    ruleneeds-decisionUpdated Sep 28, 2026
  • #28942

    PLC0414 useless-import-alias: detect in *.pyi files - mypy stubgen generates the violation

    ruleneeds-decisionUpdated Sep 28, 2026
  • #28922

    B018: useless-expression one more example to document

    ruleneeds-decisionUpdated Sep 27, 2026
  • #16401

    Ignore specific comments when formatting

    configurationformatterUpdated Sep 27, 2026
  • #1774

    Rule categorization

    coreUpdated Sep 27, 2026

> Tags

Rustlinterpep8python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 12, 2026
Category编程语言
PricingFree

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言