Skip to main content

An extremely fast Python linter, written in Rust.

Project description

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.258'
  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.

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

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ruff-0.0.258.tar.gz (823.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ruff-0.0.258-py3-none-win_arm64.whl (4.5 MB view details)

Uploaded Python 3Windows ARM64

ruff-0.0.258-py3-none-win_amd64.whl (4.7 MB view details)

Uploaded Python 3Windows x86-64

ruff-0.0.258-py3-none-win32.whl (4.4 MB view details)

Uploaded Python 3Windows x86

ruff-0.0.258-py3-none-musllinux_1_2_x86_64.whl (4.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ruff-0.0.258-py3-none-musllinux_1_2_i686.whl (4.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

ruff-0.0.258-py3-none-musllinux_1_2_armv7l.whl (4.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

ruff-0.0.258-py3-none-musllinux_1_2_aarch64.whl (4.4 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.258-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ruff-0.0.258-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (5.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

ruff-0.0.258-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (5.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

ruff-0.0.258-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (5.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64

ruff-0.0.258-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (4.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

ruff-0.0.258-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ruff-0.0.258-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.258-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (8.7 MB view details)

Uploaded Python 3macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

ruff-0.0.258-py3-none-macosx_10_7_x86_64.whl (4.5 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

Details for the file ruff-0.0.258.tar.gz.

File metadata

  • Download URL: ruff-0.0.258.tar.gz
  • Upload date:
  • Size: 823.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for ruff-0.0.258.tar.gz
Algorithm Hash digest
SHA256 cb389a8428484d25cf1225804b44e5393e061e0c425ce3fb1f6e935d5acba74b
MD5 b00f606104786ecea3e4e7994798d8e6
BLAKE2b-256 c00933cb7a57528b72c50692db7e887a665cbfbc35df1f3bcca1c2310469d468

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-win_arm64.whl.

File metadata

  • Download URL: ruff-0.0.258-py3-none-win_arm64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for ruff-0.0.258-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 7a2f74f9239407e4a88846f50142045cb2bead701cc4edae196367ce2e498e85
MD5 94a4a36a2b91c86f845af3b13370844f
BLAKE2b-256 a33aee86ffb3da44630f89a25fcd0292bbd78db540be6b56527c778f6d5f248a

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-win_amd64.whl.

File metadata

  • Download URL: ruff-0.0.258-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for ruff-0.0.258-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7e20d7209c9e51f2d6fe19e04ed674331e5fed56b819442f6ecab4a78c15890a
MD5 e8507a0d50da03d8ad86a191718a639f
BLAKE2b-256 70ef38abe24ab3c38951a3231ce267247ba869a11f6f5adb1e1f8da1c3e5e4df

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-win32.whl.

File metadata

  • Download URL: ruff-0.0.258-py3-none-win32.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for ruff-0.0.258-py3-none-win32.whl
Algorithm Hash digest
SHA256 cc9d8f7831a59d957274e24645fa57acebda1280878c2fa8e46a8c3f6284a727
MD5 713788303a4ae07f8ccaaae66e01eebd
BLAKE2b-256 901b98550f6c20da1b3f9ef5b7891a655e3d4827bf99dd33fa3764f9a333c314

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2bc3f6e7dc0ff0c916573f36aa54b671036951959f14e56956fb9bd348935ac0
MD5 b0aadd8472723b9dfbc24e4a7113564c
BLAKE2b-256 128d3a73b6121f8af0cd0e8678c224c8b3cc46869fcc0cf413253e2d3d652228

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-musllinux_1_2_i686.whl.

File metadata

  • Download URL: ruff-0.0.258-py3-none-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: Python 3, musllinux: musl 1.2+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for ruff-0.0.258-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7ecdfc38cc77fbc28cb875fe67107771ccee5fc414ccbb681f78c0ea76cb112a
MD5 41029b6751d0cae29fde3c033390331b
BLAKE2b-256 c35a0bb3df2cb6ecbd2e8a0a8fe5f8387d2736d1bc74ca988911852100cd648c

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 4b442b55981ffe8a826b6b7d31c76f93f693730f66c0948555f341ebe1e72249
MD5 93741cac18348ae9063dbb858235091d
BLAKE2b-256 179de15500cb2cc04f75e41f295ed78d6c7fb6e00c78d191331d18ed2c1a74af

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 05f7c26e60abb5fd0a8acad41e97dfaa0bafef978ef6c2406010267ef3106e1f
MD5 6603558fa600881683e2425aecea243e
BLAKE2b-256 9ee3715707ae8207b95ed3a49663d161abe4faa6cfe0a03dc8691c39c2a49d0d

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76cba6d3991a488ac5eef0efa30937603ce312bb71d5e05a517819e95c1837fe
MD5 a4b26404a976c4d28b5cd6a602d1c18f
BLAKE2b-256 9346fb2ab1b2d0e3ce6aa218d388cc39a041aa920d1a9c4d7b4292f88ed756bb

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 92205eb9ca54b30d89c34ba5e370961389cfde0c9ec6d4736ba0cce2bb83c150
MD5 a1e60d90eee6d497225280ddcc51b1f1
BLAKE2b-256 d799d2bef97951854924cbd1631d72f5dd267a92b1e4c20ccb045d19baab9d0e

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 e8ee0a7ab66c1286fd5943dc9024eb76377b35dc3380ac378626b37b23a8a802
MD5 1e1fe115efb746091a0cab06a338c3a4
BLAKE2b-256 84369810fed4cca94329c474a583a2ab48d9b0920fcab677cdfb5eac4e9f1675

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 8680dfa67946c8d8e2f17d68e44e2da9e3a1a12435cacb8c871653ed81a6030f
MD5 2adacd32489fdf5af516621549deaf8b
BLAKE2b-256 1d76b59935b0c58f927dec0cb7bcf294e2a45c41390ccfc76b62d86da9065c91

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7cef73434774a43b19c40f228dae5837d9530b08bb3b7fd3233c695572553f19
MD5 64ee5159a6f4ecd227ed9bdd249e27ba
BLAKE2b-256 a69d796afb56289129c7a94b6696dfd57dcbc1512341f8bfc9b648168c52a692

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 5b2e48a5c577605ec60f6384d8733a5d3e183109786ba2b60de2520d42594680
MD5 bbf22b7c7c0f278f2cb5ed39e698a913
BLAKE2b-256 297f10f87a0e5e9816b5767cbf0735abc1405b8e2560fe8267a6ce2b2a0839fd

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e8bab2372605a70ae94f8a19207e2b78df12b5a2ddb45890d6073913addd5aca
MD5 ab148ffc03e50877c014dc80b620b15c
BLAKE2b-256 5757d94fc4037a2dc2a8b5124e19646fceced4169dc3168f693b4b0aef93e1af

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b4d0de61317188f2e25875c41fcd5c8dba20252730d8543e43c747e9b54cf3ff
MD5 a7dd5e279b2907a07278ed4c2e862909
BLAKE2b-256 aeabcc9fb93f00c47477c3bde6980d23b28500101fe33b457665d98ec17aee53

See more details on using hashes here.

File details

Details for the file ruff-0.0.258-py3-none-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for ruff-0.0.258-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 180dd0bc1b228532eb899259f72b84779ef10fdaa0fe3695bc28611266db1036
MD5 5fb654032cd988a7d8a598c67e6a9ec8
BLAKE2b-256 b9072de74ece5f83c85c671b94a5930d4e39b9c3f6eee1f7d14fe1ef9d8cbadb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page