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.259'
  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.259.tar.gz (824.4 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.259-py3-none-win_arm64.whl (4.5 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ i686

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

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.259-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.259-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (5.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64

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

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.259-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.259-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.259.tar.gz.

File metadata

  • Download URL: ruff-0.0.259.tar.gz
  • Upload date:
  • Size: 824.4 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.259.tar.gz
Algorithm Hash digest
SHA256 8b56496063ab3bfdf72339a5fbebb8bd46e5c5fee25ef11a9f03b208fa0562ec
MD5 4e8c025e7967a4b5b48555f681f37e7f
BLAKE2b-256 46c3fb1c329c3c18c6c39920916a0952e33a5aeaa4110a0173097de761bda4bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.259-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.259-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 e4f39e18702de69faaaee3969934b92d7467285627f99a5b6ecd55a7d9f5d086
MD5 29c684101da60b4a5a65c5d62302e3b9
BLAKE2b-256 59f620ee6fa0fc1ebf4e37074d67b5a28922b3068eb7cd314d8338d0da1fd90f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.259-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.259-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 aa9449b898287e621942cc71b9327eceb8f0c357e4065fecefb707ef2d978df8
MD5 2fbccc148174ee6b9ea7b5ae48a8b1bd
BLAKE2b-256 4f56f3aa1f2f09fb2156694d52fff92aa0e2f7361df9fdfcd71b653db588b3c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.259-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.259-py3-none-win32.whl
Algorithm Hash digest
SHA256 38704f151323aa5858370a2f792e122cc25e5d1aabe7d42ceeab83da18f0b456
MD5 69da59de2f345e06696a0953cb88b492
BLAKE2b-256 52d6e098f1970281f4fe0dda82931fa337e322029c5c56071d045f73bc56ccf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 daaea322e7e85f4c13d82be9536309e1c4b8b9851bb0cbc7eeb15d490fd46bf9
MD5 4305a6fc0f7b61528d31242d26fb4b2c
BLAKE2b-256 ea1f3c54526365be3fa1577e5019bb9f76a075b1f036cecee8e43a768fcca233

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.259-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.259-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 5b3c1beacf6037e7f0781d4699d9a2dd4ba2462f475be5b1f45cf84c4ba3c69d
MD5 235c66844284315c5e9e74580878b44f
BLAKE2b-256 3b61970caf64ea02efe5d452b9f854c3a84e75e1e4367a17c5de9a792c1b7d79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 29e2b77b7d5da6a7dd5cf9b738b511355c5734ece56f78e500d4b5bffd58c1a0
MD5 4972aebb834900fc43d43c383732c614
BLAKE2b-256 13cde2d1f87ca879680635133ea377eb89643593f60def3657e2c628feb9013e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 40ae87f2638484b7e8a7567b04a7af719f1c484c5bf132038b702bb32e1f6577
MD5 253be94227a3d043b10afe0ad5721b68
BLAKE2b-256 b900867b2e4ac6417056df29afd721a6570fe8b62af727773f7f17858e8e907e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5fbaea9167f1852757f02133e5daacdb8c75b3431343205395da5b10499927a
MD5 615b10292f245408061694e9da6f122f
BLAKE2b-256 d127293237bf480f89331681bcc27d1d50a2f5b330a67d325ae400d9db0e5b40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 428507fb321b386dda70d66cd1a8aa0abf51d7c197983d83bb9e4fa5ee60300b
MD5 9da834ca7e792e610ce105b9df70c77a
BLAKE2b-256 96983be208b743fec49513016d26f4a3203ce7388cbd849f0ca7c6998784a72b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 79b02fa17ec1fd8d306ae302cb47fb614b71e1f539997858243769bcbe78c6d9
MD5 2e2b5d9fc99dfb6b2e1f6baaa04e213b
BLAKE2b-256 83889523abb56a2241fe9e6fe43d2c231025021f73fb9a56d8003182cd1804fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 7cfef26619cba184d59aa7fa17b48af5891d51fc0b755a9bc533478a10d4d066
MD5 3e820bb492f2abbf85932d31c50c97b2
BLAKE2b-256 ea357fd199429e7bf3849f2c378bb4ed24d31be467fd7c7f9007e0919b36202c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 71f0ef1985e9a6696fa97da8459917fa34bdaa2c16bd33bd5edead585b7d44f7
MD5 3ca3e364bd503aae8189a14513eab828
BLAKE2b-256 e34dd626d94852a215ba3a1871ac0edb6e0112b6c195ed9e137ca90cdf9d0c2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 49e903bcda19f6bb0725a962c058eb5d61f40d84ef52ed53b61939b69402ab4e
MD5 b95efd5fb10a9d40137b03bb884e43e9
BLAKE2b-256 6094358e91257dd09be78f6af6be3433209d289662f9cdd636d1b2475e979dc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d2fb20e89e85d147c85caa807707a1488bccc1f3854dc3d53533e89b52a0c5ff
MD5 87e2edcaf49332ac066e7f5c97157491
BLAKE2b-256 d7bc5ebbb959517b105f50dec7b47841d2a5e8dec17c0d7bbfa11253415a79e0

See more details on using hashes here.

File details

Details for the file ruff-0.0.259-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.259-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 22e1e35bf5f12072cd644d22afd9203641ccf258bc14ff91aa1c43dc14f6047d
MD5 cd9175614bd16c3714adeedd8f4d3b7d
BLAKE2b-256 6e1264b492d704e88e76ef7b42458966115559d7dd8b03dcd3ddaec56a6f21db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.259-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f3938dc45e2a3f818e9cbd53007265c22246fbfded8837b2c563bf0ebde1a226
MD5 1b3d187679997fb3a63afc41087f3104
BLAKE2b-256 cb1836e715ccc7cff6daa9a2e8493de6abc3c761b470fc24cbaf8e6a6c0ad870

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