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

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.257.tar.gz (797.1 kB view details)

Uploaded Source

Built Distributions

ruff-0.0.257-py3-none-win_arm64.whl (3.5 MB view details)

Uploaded Python 3Windows ARM64

ruff-0.0.257-py3-none-win_amd64.whl (3.7 MB view details)

Uploaded Python 3Windows x86-64

ruff-0.0.257-py3-none-win32.whl (3.6 MB view details)

Uploaded Python 3Windows x86

ruff-0.0.257-py3-none-musllinux_1_2_x86_64.whl (4.2 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ruff-0.0.257-py3-none-musllinux_1_2_i686.whl (3.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

ruff-0.0.257-py3-none-musllinux_1_2_armv7l.whl (3.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

ruff-0.0.257-py3-none-musllinux_1_2_aarch64.whl (3.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.257-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ruff-0.0.257-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (4.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

ruff-0.0.257-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (4.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

ruff-0.0.257-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (4.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64

ruff-0.0.257-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

ruff-0.0.257-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ruff-0.0.257-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.257-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (7.7 MB view details)

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

ruff-0.0.257-py3-none-macosx_10_7_x86_64.whl (4.1 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: ruff-0.0.257.tar.gz
  • Upload date:
  • Size: 797.1 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.257.tar.gz
Algorithm Hash digest
SHA256 fedfd06a37ddc17449203c3e38fc83fb68de7f20b5daa0ee4e60d3599b38bab0
MD5 cc554e517cadfd6f4495739b6b8916db
BLAKE2b-256 03fac50057dc525c9c4f9babc2f22838645e53034f2802c7204c669b620ab0dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.257-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.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.257-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 352f1bdb9b433b3b389aee512ffb0b82226ae1e25b3d92e4eaf0e7be6b1b6f6a
MD5 c024fd1b663e5cf8c49183cbc5ba350b
BLAKE2b-256 95457f40ff972e5a48dc51120c79b03202e0654b3c5cb511a4283183a0ce13b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.257-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.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.257-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3cec07d6fecb1ebbc45ea8eeb1047b929caa2f7dfb8dd4b0e1869ff789326da5
MD5 a367d457bc648b2fe1c22938d0e623c3
BLAKE2b-256 e8ea86373c1917fbc7a3f6d28c4a41f118b8d07b5d53be506ada25f48053443c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.257-py3-none-win32.whl
  • Upload date:
  • Size: 3.6 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.257-py3-none-win32.whl
Algorithm Hash digest
SHA256 d2c8755fa4f6c5e5ec032ad341ca3beeecd16786e12c3f26e6b0cc40418ae998
MD5 e737a936e808c12b877ebee18c5b058a
BLAKE2b-256 52f4349cfb878df4659c353b48b4f1c9ae668826e48781b8665c510c7c1677c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3db8d77d5651a2c0d307102d717627a025d4488d406f54c2764b21cfbe11d822
MD5 15b4bb94aad36e8a444366e2114b0b28
BLAKE2b-256 9df8532c0472f9886c32a04403b219a50e8b446e11e9bf4978d2bcdbc20c6d4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.257-py3-none-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 3.9 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.257-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4ecd7a84db4816df2dcd0f11c5365a9a2cf4fa70a19b3ac161b7b0bfa592959d
MD5 0266ca5cf44843408b18a821c65f3545
BLAKE2b-256 8adc18263d599925c7e8f4001bb6715698db654acc13cc68a733d093044ac72f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 aaa3b5b6929c63a854b6bcea7a229453b455ab26337100b2905fae4523ca5667
MD5 cc52369e9818d29af2d6f04595490d21
BLAKE2b-256 d224ff82d955c9e65671d8237afff6bee25ad4c1933d7a10f07187937b178d2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 783390f1e94a168c79d7004426dae3e4ae2999cc85f7d00fdd86c62262b71854
MD5 15d7e5b01d916d779d04a0de3ac65606
BLAKE2b-256 325a4829bade5075c95fbee423d66ae69143cac028f5ef6f85f7b63ae40ebdbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 358cc2b547bd6451dcf2427b22a9c29a2d9c34e66576c693a6381c5f2ed3011d
MD5 86834dd8d2df8728c7a7f696600af71e
BLAKE2b-256 0c1fbb660d5fbc43c67d87834093271c06421453d31eff2c9798c74f4e58c791

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 3438fd38446e1a0915316f4085405c9feca20fe00a4b614995ab7034dbfaa7ff
MD5 6b3673d75a8f6998f00f8318606b00e4
BLAKE2b-256 6deafe95f51b4b07716813a78089909530bcf009b6fe2e95a164079cf4c4141f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 5a54bfd559e558ee0df2a2f3756423fe6a9de7307bc290d807c3cdf351cb4c24
MD5 c0bd59a43b057a7f60afdbe10404412f
BLAKE2b-256 08c378a7fa4a7721e2b49e45bdb63ae4758648cfee306dd656eb21cf8540de24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 3464f1ad4cea6c4b9325da13ae306bd22bf15d226e18d19c52db191b1f4355ac
MD5 912cfa88720258ff3f023a6bf8b346ec
BLAKE2b-256 b6f6e52f410d06cb5c0b7fbadb84b691ef2cebc21928a9ed70a94fc1c38afe40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4a9542c34ee5298b31be6c6ba304f14b672dcf104846ee65adb2466d3e325870
MD5 12de1079da998f343bac3ed71c00a971
BLAKE2b-256 4a3dc095e62641d7cd226890d6d437ff65215e2b8d03f0e1df973d66131acd06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 d9f0912d045eee15e8e02e335c16d7a7f9fb6821aa5eb1628eeb5bbfa3d88908
MD5 c0cb0f0768c6b2ff4a2e35d6e86a50c9
BLAKE2b-256 481b3b22dd11bfb76be393fbb3ad1cbaf783d49729ea66dcb9867430c18b9373

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5acae9878f1136893e266348acdb9d30dfae23c296d3012043816432a5abdd51
MD5 b9a5b82122dd4bb89d182a370c807761
BLAKE2b-256 a7ecce5a0b11ad4c5ac8f78ca7ca6d98d7bb5c9e37fda3520ed89bbd86ee77c6

See more details on using hashes here.

File details

Details for the file ruff-0.0.257-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.257-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4582b73da61ab410ffda35b2987a6eacb33f18263e1c91810f0b9779ec4f41a9
MD5 52463e82a19fd27d940ab1edf2b88c55
BLAKE2b-256 7a7d686fbdfa4a898d22beae05542085525649468a2c7f0738c7cacfc63a815e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.257-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7280640690c1d0046b20e0eb924319a89d8e22925d7d232180ce31196e7478f8
MD5 3d457cf63f69360db634dc4169a2c90d
BLAKE2b-256 e3829c70235d8943fab4673cccd4b9881fce2943238ce5c8f4d6b55efa2f90fa

See more details on using hashes here.

Supported by

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