API Reference

Ruff

An extremely fast Python linter and formatter written in Rust, replacing multiple tools with one binary.

Official Documentation ↗
CompatibilityThis documentation covers version v0.4. Check the official docs for the latest API surface.

Installation

pippip install ruff

Methods

Ruff lints and formats Python at native speed and configures rules through pyproject.toml.

Key Features

  • Extremely fast Rust implementation
  • Hundreds of lint rules and auto-fixes
  • Built-in formatter compatible with Black

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://docs.astral.sh/ruff/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:16.849Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

  • Only one downside so far: it’s so fast I couldn’t believe it was working till I intentionally introduced some errors. (https://docs.astral.sh/ruff/)

FAQ

Can it replace Black and isort?
Yes. ruff format covers Black formatting and the isort rules handle import sorting, often removing both tools from CI.
How do I see what a rule means?
Run ruff rule <code> to print the documentation for a specific check and an example of the violation.
How do I ignore a line?
Add a # noqa: <code> comment on the line, or use per-file ignores in configuration for generated files.