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 (and growing)
  • ⚖️ 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.253'
  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",
]
per-file-ignores = {}

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

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.253.tar.gz (742.3 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.253-py3-none-win_arm64.whl (3.3 MB view details)

Uploaded Python 3Windows ARM64

ruff-0.0.253-py3-none-win_amd64.whl (3.6 MB view details)

Uploaded Python 3Windows x86-64

ruff-0.0.253-py3-none-win32.whl (3.5 MB view details)

Uploaded Python 3Windows x86

ruff-0.0.253-py3-none-musllinux_1_2_x86_64.whl (4.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ruff-0.0.253-py3-none-musllinux_1_2_i686.whl (3.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

ruff-0.0.253-py3-none-musllinux_1_2_armv7l.whl (3.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

ruff-0.0.253-py3-none-musllinux_1_2_aarch64.whl (3.7 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.253-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ruff-0.0.253-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

ruff-0.0.253-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (4.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

ruff-0.0.253-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (4.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64

ruff-0.0.253-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (4.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

ruff-0.0.253-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ruff-0.0.253-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.253-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (7.5 MB view details)

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

ruff-0.0.253-py3-none-macosx_10_7_x86_64.whl (4.0 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: ruff-0.0.253.tar.gz
  • Upload date:
  • Size: 742.3 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.253.tar.gz
Algorithm Hash digest
SHA256 ab746c843a9673d2637bcbcb45da12ed4d44c0c90f0823484d6dcb660118b539
MD5 6f06ad9dfb7ff02f9c5a7eb484789d5d
BLAKE2b-256 e1fca199bc6a1f49d66b4dd275600147de3d4ec7832c1315543ed3597c8841b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.253-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.3 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.253-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 506987ac3bc212cd74bf1ca032756e67ada93c4add3b7541e3549bbad5e0fc40
MD5 821c0fe4237ea36c1641e7c0819b5931
BLAKE2b-256 c456b4193aeb490fcfabe99b35893dd3def6bde8422b9867d2e6b0befe742576

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.253-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.253-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a64e9f97a6b0bfce924e65fa845f669c969d42c30fb61e1e4d87b2c70d835cb9
MD5 0f77ad7b7b94d730e5e6dc4cc2e12e08
BLAKE2b-256 f275dba706febaac36c5b7f608d758aee5e1a2e1bfeaf4b1594273cae010534e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.253-py3-none-win32.whl
  • Upload date:
  • Size: 3.5 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.253-py3-none-win32.whl
Algorithm Hash digest
SHA256 a66109185382375246d7b0dae2f594801fd8ceb5f8206159c55791aaec9aa4bb
MD5 b442adcc9843493bc6ad72567ac3f5e9
BLAKE2b-256 96345d5746981efe14fedf7f39437991d8016fd26337cc7b40441c6e97b16b70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e2485f728f04bf3bd6142e55dd2869c769299b73a4bdbe1a795e98332df75561
MD5 b2f5eaed7665a466d2da5fb9febf2a94
BLAKE2b-256 0b76c7735cacfaf4a4c2d0e674f8274d45b387b586b574c337a001a3871e818c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.253-py3-none-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 3.8 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.253-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4548734b2671b80ee4c20aa410d7d2a5b32f087f8759d4f5991c74b8cfa51d7b
MD5 d383a44f2cae86902ca7f1a275fe5c2a
BLAKE2b-256 533458bf14786a311b99025d076808417197dd9540bc376b7c071c641673bf71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 f0ff811ea61684c6e9284afa701b8388818ab5ef8ebd6144c15c9ba64f459f1e
MD5 0c5bfe03efd96a7c752b5d4e0afc5c84
BLAKE2b-256 731e041eb2737fd1240a9cf190f9700f7040c544cebfbd1c16aab111a9194bb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6ee92a7688f327c664891567aa24e4a8cae8635934df95e0dbe65b0e991fcc6e
MD5 7e2b0791c60d90e6075d7c8868308bd0
BLAKE2b-256 17e6271441a3e6aec29837b134bc225867d845ce2da6a446f1d2431028411293

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19061d9b5809a0505a233580b48b59b847823ab90e266f8ae40cb31d3708bacf
MD5 656fc52376b664341e2ddb62ddc9c5b6
BLAKE2b-256 f0896b9af5a8b2111ffb860b3bf475b8261baed0fa9a8e1393eb08c29e06a963

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 60bda6fd99f9d3919df4362b671a12c83ef83279fc7bc1dc0e1aa689dfd91a71
MD5 20b32de0abd7a7c0ab3a1221c9b3e9fb
BLAKE2b-256 42eb922be4e778d511e0e9714f177d0d04729760d3c3b1b80937db414f724bbc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 ba4b3921fa9c59855b66e1a5ef140d0d872f15a83282bff5b5e3e8db89a45aa2
MD5 6220e843f9197db4898e608fbc7b4927
BLAKE2b-256 096d8f03196c0e2310c75408ed4f9a011f1a1cf91ceb31cb8de56febfcc30eb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 c6ed42010c379d42b81b537957b413cf8531a00d0a6270913e8527d9d73c7e0c
MD5 4eda848fe68e08e9aa10f09ee3207f05
BLAKE2b-256 c79935a48d407f063435319f63515afb116f3567f35235fc2ee57c09342da44b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 68f9a50f48510a443ec57bcf51656bbef47e5972290c450398108ac2a53dfd32
MD5 28a76e25dcf317bd123dbcd95be819b0
BLAKE2b-256 34c25e75d71e38df53413c400739e2ecffa80e3f74c5596e5e2978ba4979d3b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 07603b362f0dad56e30e7ef2f37bf480732ff8bcf52fe4fd6c9445eb42259f42
MD5 7212051db176f4bd16cae3302a183a8a
BLAKE2b-256 b7c2e829eabb8bcdfad21761a36033519e6d6282042a723ce59e58941dabb45e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8144a2fd6533e7a0dbaaf9a3dde44b8414eebf5a86a1fe21e0471d052a3e9c14
MD5 b2d90a2c69651902c1bcee7aac38078c
BLAKE2b-256 90b028c1baad7eea67287caca6ff4fc1a505b835686aa30c2da09036eff8d79a

See more details on using hashes here.

File details

Details for the file ruff-0.0.253-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.253-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0f44caf5bbdaeacc3cba4ee3369638e4f6e4e71c9ca773d2f3fc3f65e4bfb434
MD5 8709fd149904c234bffc17d34b6824ef
BLAKE2b-256 482290f52fc20620c269c1a2c679c78298bca0e03d66c646a2a267a6d5ff5977

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.253-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 69126b80d4da50a394cfe9da947377841cc6c83b0e05cfe9933672ce5c61bfcf
MD5 e1bda61b13101e29c8556521f781857a
BLAKE2b-256 db8cd1a82d4e31c76341951f8548f01731c6e9a87f6008da6f95d31de4be3928

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