Skip to main content

Ruff

Ruff image image image Actions status

Discord | Docs | Playground

An extremely fast Python linter, written in Rust.

Shows a bar chart with benchmark results.

Linting the CPython codebase from scratch.

  • ⚡️ 10-100x faster than existing linters
  • 🐍 Installable via pip
  • 🛠️ pyproject.toml support
  • 🤝 Python 3.11 compatibility
  • 📦 Built-in caching, to avoid re-analyzing unchanged files
  • 🔧 Autofix support, for automatic error correction (e.g., automatically remove unused imports)
  • 📏 Over 500 built-in rules
  • ⚖️ Near-parity with the built-in Flake8 rule set
  • 🔌 Native re-implementations of dozens of 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), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, 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:

...and many more.

Read the launch blog post or the most recent project update.

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:

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:

pip install ruff

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

Usage

To run Ruff, try any of the following:

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 can also be used as a pre-commit hook:

- repo: https://github.com/charliermarsh/ruff-pre-commit
  # Ruff version.
  rev: 'v0.0.257'
  hooks:
    - id: ruff

Ruff can also be used as a VS Code extension or alongside any other editor through the Ruff LSP.

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).

If left unspecified, the default configuration is equivalent to:

[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "..."]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
]

# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

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

ruff check path/to/code/ --select F401 --select F403 --quiet

See ruff help for more on Ruff's top-level commands, or ruff help check for more on the linting command.

Rules

Ruff supports over 500 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 Flake8's E and F rules. Ruff supports all rules from the F category, and a subset of the E category, omitting those stylistic rules made obsolete by the use of an autoformatter, like 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.

For a complete enumeration of the supported rules, see Rules.

Contributing

Contributions are welcome and highly appreciated. To get started, check out the contributing guidelines.

You can also join us on Discord.

Support

Having trouble? Check out the existing issues on GitHub, or feel free to open a new one.

You can also ask for help on Discord.

Acknowledgements

Ruff's linter draws on both the APIs and implementation details of many other tools in the Python ecosystem, especially Flake8, Pyflakes, pycodestyle, pydocstyle, pyupgrade, and isort.

In some cases, Ruff includes a "direct" Rust port of the corresponding tool. We're grateful to the maintainers of these tools for their work, and for all the value they've provided to the Python community.

Ruff's autoformatter is built on a fork of Rome's rome_formatter, and again draws on both the APIs and implementation details of Rome, Prettier, and Black.

Ruff is also influenced by a number of tools outside the Python ecosystem, like Clippy and ESLint.

Ruff is the beneficiary of a large number of contributors.

Ruff is released under the MIT license.

Who's Using Ruff?

Ruff is used in a number of major open-source projects, including:

License

MIT

Metadata

Release files for ruff 0.0.257

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ruff 0.0.257
File Size Uploaded
ruff-0.0.257.tar.gz 797.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ruff 0.0.257
File
ruff-0.0.257-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
ruff-0.0.257-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
ruff-0.0.257-py3-none-win32.whl Python 3 none Windows x86-32 Details
ruff-0.0.257-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
ruff-0.0.257-py3-none-musllinux_1_2_i686.whl Python 3 none Linux musl 1.2+ x86-32 Details
ruff-0.0.257-py3-none-musllinux_1_2_armv7l.whl Python 3 none Linux musl 1.2+ ARMv7l Details
ruff-0.0.257-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
ruff-0.0.257-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
ruff-0.0.257-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl Python 3 none Linux glibc 2.17+ IBM System/390x Details
ruff-0.0.257-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl Python 3 none Linux glibc 2.17+ PowerPC 64-le Details
ruff-0.0.257-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl Python 3 none Linux glibc 2.17+ PowerPC 64-be Details
ruff-0.0.257-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl Python 3 none Linux glibc 2.17+ x86-32 Details
ruff-0.0.257-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details
ruff-0.0.257-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
ruff-0.0.257-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl Python 3 none macOS 11.0+ ARM64, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64 Details
ruff-0.0.257-py3-none-macosx_10_7_x86_64.whl Python 3 none macOS 10.7+ x86-64 Details

Total release size: 68.7 MB

Release files / ruff-0.0.257.tar.gz

Download URL ruff-0.0.257.tar.gz
Size 797.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fedfd06a37ddc17449203c3e38fc83fb68de7f20b5daa0ee4e60d3599b38bab0
BLAKE2b-256 checksum
How to use checksums
03fac50057dc525c9c4f9babc2f22838645e53034f2802c7204c669b620ab0dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-win_arm64.whl

Download URL ruff-0.0.257-py3-none-win_arm64.whl
Size 3.5 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
352f1bdb9b433b3b389aee512ffb0b82226ae1e25b3d92e4eaf0e7be6b1b6f6a
BLAKE2b-256 checksum
How to use checksums
95457f40ff972e5a48dc51120c79b03202e0654b3c5cb511a4283183a0ce13b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-win_amd64.whl

Download URL ruff-0.0.257-py3-none-win_amd64.whl
Size 3.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
3cec07d6fecb1ebbc45ea8eeb1047b929caa2f7dfb8dd4b0e1869ff789326da5
BLAKE2b-256 checksum
How to use checksums
e8ea86373c1917fbc7a3f6d28c4a41f118b8d07b5d53be506ada25f48053443c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-win32.whl

Download URL ruff-0.0.257-py3-none-win32.whl
Size 3.6 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
d2c8755fa4f6c5e5ec032ad341ca3beeecd16786e12c3f26e6b0cc40418ae998
BLAKE2b-256 checksum
How to use checksums
52f4349cfb878df4659c353b48b4f1c9ae668826e48781b8665c510c7c1677c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-musllinux_1_2_x86_64.whl

Download URL ruff-0.0.257-py3-none-musllinux_1_2_x86_64.whl
Size 4.2 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
3db8d77d5651a2c0d307102d717627a025d4488d406f54c2764b21cfbe11d822
BLAKE2b-256 checksum
How to use checksums
9df8532c0472f9886c32a04403b219a50e8b446e11e9bf4978d2bcdbc20c6d4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-musllinux_1_2_i686.whl

Download URL ruff-0.0.257-py3-none-musllinux_1_2_i686.whl
Size 3.9 MB
Tags Linux musl 1.2+ x86-32 Python 3
SHA-256 checksum
How to use checksums
4ecd7a84db4816df2dcd0f11c5365a9a2cf4fa70a19b3ac161b7b0bfa592959d
BLAKE2b-256 checksum
How to use checksums
8adc18263d599925c7e8f4001bb6715698db654acc13cc68a733d093044ac72f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-musllinux_1_2_armv7l.whl

Download URL ruff-0.0.257-py3-none-musllinux_1_2_armv7l.whl
Size 3.6 MB
Tags Linux musl 1.2+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
aaa3b5b6929c63a854b6bcea7a229453b455ab26337100b2905fae4523ca5667
BLAKE2b-256 checksum
How to use checksums
d224ff82d955c9e65671d8237afff6bee25ad4c1933d7a10f07187937b178d2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-musllinux_1_2_aarch64.whl

Download URL ruff-0.0.257-py3-none-musllinux_1_2_aarch64.whl
Size 3.9 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
783390f1e94a168c79d7004426dae3e4ae2999cc85f7d00fdd86c62262b71854
BLAKE2b-256 checksum
How to use checksums
325a4829bade5075c95fbee423d66ae69143cac028f5ef6f85f7b63ae40ebdbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.2 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
358cc2b547bd6451dcf2427b22a9c29a2d9c34e66576c693a6381c5f2ed3011d
BLAKE2b-256 checksum
How to use checksums
0c1fbb660d5fbc43c67d87834093271c06421453d31eff2c9798c74f4e58c791
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 4.8 MB
Tags Linux glibc 2.17+ IBM System/390x Python 3
SHA-256 checksum
How to use checksums
3438fd38446e1a0915316f4085405c9feca20fe00a4b614995ab7034dbfaa7ff
BLAKE2b-256 checksum
How to use checksums
6deafe95f51b4b07716813a78089909530bcf009b6fe2e95a164079cf4c4141f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 4.5 MB
Tags Linux glibc 2.17+ PowerPC 64-le Python 3
SHA-256 checksum
How to use checksums
5a54bfd559e558ee0df2a2f3756423fe6a9de7307bc290d807c3cdf351cb4c24
BLAKE2b-256 checksum
How to use checksums
08c378a7fa4a7721e2b49e45bdb63ae4758648cfee306dd656eb21cf8540de24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Size 4.6 MB
Tags Linux glibc 2.17+ PowerPC 64-be Python 3
SHA-256 checksum
How to use checksums
3464f1ad4cea6c4b9325da13ae306bd22bf15d226e18d19c52db191b1f4355ac
BLAKE2b-256 checksum
How to use checksums
b6f6e52f410d06cb5c0b7fbadb84b691ef2cebc21928a9ed70a94fc1c38afe40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Size 4.1 MB
Tags Linux glibc 2.17+ x86-32 Python 3
SHA-256 checksum
How to use checksums
4a9542c34ee5298b31be6c6ba304f14b672dcf104846ee65adb2466d3e325870
BLAKE2b-256 checksum
How to use checksums
4a3dc095e62641d7cd226890d6d437ff65215e2b8d03f0e1df973d66131acd06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 3.6 MB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
d9f0912d045eee15e8e02e335c16d7a7f9fb6821aa5eb1628eeb5bbfa3d88908
BLAKE2b-256 checksum
How to use checksums
481b3b22dd11bfb76be393fbb3ad1cbaf783d49729ea66dcb9867430c18b9373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL ruff-0.0.257-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.9 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
5acae9878f1136893e266348acdb9d30dfae23c296d3012043816432a5abdd51
BLAKE2b-256 checksum
How to use checksums
a7ecce5a0b11ad4c5ac8f78ca7ca6d98d7bb5c9e37fda3520ed89bbd86ee77c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL ruff-0.0.257-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 7.7 MB
Tags Python 3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4582b73da61ab410ffda35b2987a6eacb33f18263e1c91810f0b9779ec4f41a9
BLAKE2b-256 checksum
How to use checksums
7a7d686fbdfa4a898d22beae05542085525649468a2c7f0738c7cacfc63a815e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / ruff-0.0.257-py3-none-macosx_10_7_x86_64.whl

Download URL ruff-0.0.257-py3-none-macosx_10_7_x86_64.whl
Size 4.1 MB
Tags Python 3 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
7280640690c1d0046b20e0eb924319a89d8e22925d7d232180ce31196e7478f8
BLAKE2b-256 checksum
How to use checksums
e3829c70235d8943fab4673cccd4b9881fce2943238ce5c8f4d6b55efa2f90fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

0.9.9

18 release files

0.9.8

18 release files

0.9.7

18 release files

0.9.6

18 release files

0.9.4

18 release files

0.9.3

18 release files

0.9.2

18 release files

0.9.1

18 release files

0.8.4

18 release files

0.8.3

18 release files

0.8.1

18 release files

0.8.0

18 release files

0.7.4

18 release files

0.7.1

18 release files

0.7.0

18 release files

0.6.8

18 release files

0.6.7

18 release files

0.6.6

18 release files

0.6.5

18 release files

0.6.3

18 release files

0.6.2

18 release files

0.6.1

18 release files

0.6.0

18 release files

0.5.5

18 release files

0.5.4

18 release files

0.5.3

18 release files

0.5.2

18 release files

0.5.0

18 release files

0.4.9

17 release files

0.4.7

17 release files

0.4.6

17 release files

0.4.5

17 release files

0.4.2

17 release files

0.4.1

17 release files

0.4.0

17 release files

0.3.7

17 release files

0.3.6

17 release files

0.3.4

17 release files

0.3.3

17 release files

0.3.0

17 release files

0.2.2

17 release files

0.1.9

17 release files

0.1.8

17 release files

0.1.6

17 release files

0.1.3

17 release files

0.1.2

17 release files

0.1.1

17 release files

0.1.0

17 release files

This release

0.0.257 This release

17 release files

0.0.16

9 release files

0.0.15

3 release files

0.0.14

3 release files

0.0.13

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page