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.255'
  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.255.tar.gz (786.8 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.255-py3-none-win_arm64.whl (3.5 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ i686

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

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

ruff-0.0.255-py3-none-musllinux_1_2_aarch64.whl (3.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.255-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.255-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (4.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64

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

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.255-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.255-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.255.tar.gz.

File metadata

  • Download URL: ruff-0.0.255.tar.gz
  • Upload date:
  • Size: 786.8 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.255.tar.gz
Algorithm Hash digest
SHA256 f9eb1d3b2eecbeedae419fa494c4e2a5e4484baf93a1ce0f81eddb005e1919c5
MD5 09b49dfdef35ee00b350b31384b6c4b1
BLAKE2b-256 410de1368ba618143f408a898bff02cf315fa8b78f43c6c51a37941c1cde0405

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.255-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.255-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 8ba124819624145d7b6b53add40c367c44318893215ffc1bfe3d72e0225a1c9c
MD5 65a2ec2d68d3f87c513f7c80e1fbb9ff
BLAKE2b-256 969623f43ae8d7e4062ed1264e15c88e1b7673266bd9c04e58883c259c403fe2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.255-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.255-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f3d8416be618f023f93ec4fd6ee3048585ef85dba9563b2a7e38fc7e5131d5b1
MD5 f40d6e2388be2b9e187e942b2c6d8071
BLAKE2b-256 67b6d6a06566c63a38862211d8c82d9fdf6a0d042ccaa135287646dd8b831a25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.255-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.255-py3-none-win32.whl
Algorithm Hash digest
SHA256 1ff87a8310354f9f1a099625e54a27fdd6756d9cd2a40b45922f2e943daf982d
MD5 822d4fd01fcaf7bef717e222f80a7049
BLAKE2b-256 da11e0870ecb61bcc7b5afbd40c6d28d9577feb61a07d6042edfda4aac437332

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6a25c5f4ff087445b2e1bbcb9963f2ae7c868d65e4a8d5f84c36c12f71571179
MD5 e3a9be2e0fdbac46636997297903bcfc
BLAKE2b-256 84f8721c81532ca3631db35bd8b5e99a674a16696220c84fb1d55d31ed081bc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.255-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.255-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 f9b1a5df0bc09193cbef58a6f78e4a9a0b058a4f9733c0442866d078006d1bb9
MD5 0d061e96a28ec9a9b1c3c09327b1437c
BLAKE2b-256 8f6b9baa4b7e6de8c249f200f838deb3be4ed42634ef3853244cf32312c3f387

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 abd6376ef9d12f370d95a8c7c98682fbb9bfedfba59f40e84a816fef8ddcb8de
MD5 bbe22df3abe217b996b7e884cb4ea4bb
BLAKE2b-256 41dff62301fcbc27f86545a41f364de9d2bd13775766de30e5bbc81b176c5fce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5d0408985c9777369daebb5d3340a99e9f7294bdd7120642239261508185cf89
MD5 e0a43b5ebe8f67c4b215e125e9ac5b91
BLAKE2b-256 2a43cac02dc28a4b82655930ee87dcd59ade6ff9a171e20c44f392fb26153c08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 694418cf41838bd19c6229e4e1b2d04505b1e6b86fe3ab81165484fc96d36f01
MD5 3087ba40f6c9a248cd6c474c9fb37034
BLAKE2b-256 4b094b69497bd04af2cc553cd7aa11c32bc5fb92f2277b49982973c28fa0f739

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 dd5e00733c9d160c8a34a22e62b390da9d1e9f326676402421cb8c1236beefc3
MD5 4bffb81f5f53b1cf5d7f5816e44fb9f6
BLAKE2b-256 390d90377c8729a4bb91024b420c15d4d65f24a6121721cf234224424208910d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 59d5193d2aedb35db180824462b374dbcfc306b2e76076245088afa6e5837df2
MD5 6702236ef68bd769ec716e7dd3ad171c
BLAKE2b-256 5711d9761aad4058d63935491b1e799385df523967e5dad9b3e3cfaef260476a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 981493e92547cacbb8e0874904ec049fe744507ee890dc8736caf89a8864f9a7
MD5 dec3b94d82a31a3e3fdb79caf14e1aee
BLAKE2b-256 5d7d108c6c9e3cbea29dd55c749b39dce428a654b4c3ada85e56aefc736324f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 0423908caa7d437a416b853214565b9c33bbd1106c4f88147982216dddcbbd96
MD5 5dec94f5c895516e50246a00bb7928ab
BLAKE2b-256 180ecaa5c335d620534ca939b7bd7a5946e51302f6c8ca2fe93d8c3e9e874cb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 c089f7141496334ab5a127b54ce55e41f0d6714e68a4453a1e09d2204cdea8c3
MD5 e47c04d3ddeb3e719e7738ffed55c6e6
BLAKE2b-256 94de2d5d55128a4fd03312e68e1ee4384bb31c84bce1d67f62b1d60f04bf75f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9a7fa60085079b91a298b963361be9b1b1c724582af6c84be954cbabdbd9309a
MD5 eb2d4049a9320f66a71f76d079f3f8ef
BLAKE2b-256 30749fbc7f77a4fe5a0c8e4501b47140c54c04639c6e8cdad5afcb5078fce6ae

See more details on using hashes here.

File details

Details for the file ruff-0.0.255-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.255-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 6c97d746861a6010f941179e84bba9feb8a871815667471d9ed6beb98d45c252
MD5 896808f283615001b4ad87fb434a4afd
BLAKE2b-256 bd2af9bc0d32adf4805fa1311c0692436009cbf184bba38baf2479c4faa10b49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.255-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b2d71fb6a7e50501a2473864acffc85dee6b750c25db198f7e71fe1dbbff1aad
MD5 4cd542c51c4648d86b23ae76baa63d5c
BLAKE2b-256 ce18fa36c6789ef66e842af6d1b6ecb9f88157097176b36108a47ddf158cf1d2

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