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.254'
  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.254.tar.gz (756.9 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.254-py3-none-win_arm64.whl (3.4 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ i686

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

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.254-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.254-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64

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

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ruff-0.0.254-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.254-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (7.6 MB view details)

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

ruff-0.0.254-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.254.tar.gz.

File metadata

  • Download URL: ruff-0.0.254.tar.gz
  • Upload date:
  • Size: 756.9 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.254.tar.gz
Algorithm Hash digest
SHA256 0eb66c9520151d3bd950ea43b3a088618a8e4e10a5014a72687881e6f3606312
MD5 c9e20f9fff014dd155776a7ab5eb0f52
BLAKE2b-256 93b414cb42614daf79be830a922325d982ea31f64c5ade1b312df34b331ed377

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.254-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.4 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.254-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 b435afc4d65591399eaf4b2af86e441a71563a2091c386cadf33eaa11064dc09
MD5 b4aca72b3342a6b511d738541a0d5014
BLAKE2b-256 e151d7becc071c5f60e99f302d6d01caea92cafebab92a6564f8bd04863a1a52

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.254-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.254-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e15742df0f9a3615fbdc1ee9a243467e97e75bf88f86d363eee1ed42cedab1ec
MD5 08dd6ed9aa2a4a78b04f9fd158c01871
BLAKE2b-256 c5b7ba6612578495e62b2e73e168fba52bc7f052dfe151e0974e16b8e4dc312e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.254-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.254-py3-none-win32.whl
Algorithm Hash digest
SHA256 c38291bda4c7b40b659e8952167f386e86ec29053ad2f733968ff1d78b4c7e15
MD5 17502d6fbf49c66731859df01696378d
BLAKE2b-256 24b7e95dd46aa08db9297fd9835a971a77709124d8afe44c753ce7e27cbb610e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d4385cdd30153b7aa1d8f75dfd1ae30d49c918ead7de07e69b7eadf0d5538a1f
MD5 e8924e81431a16ae3e6fa858c1c43054
BLAKE2b-256 aa6672e8531e8c1478be542097c6e0ca7d4579f0d950c1c081ed2ede082ee7ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 09c764bc2bd80c974f7ce1f73a46092c286085355a5711126af351b9ae4bea0c
MD5 787622c4dd6426db9cc3138c8361ba83
BLAKE2b-256 292f9d1c05003494c445a1bc6b6fb14baf098ed0e3683d7bc3aaa3333439e908

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 f70dc93bc9db15cccf2ed2a831938919e3e630993eeea6aba5c84bc274237885
MD5 7d1e9e76d55bc5355b74405fb474bb12
BLAKE2b-256 147086a68a61322b1a342481e8e33db94e09eac352ca472058f2f691d6fd7b8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2fc21d060a3197ac463596a97d9b5db2d429395938b270ded61dd60f0e57eb21
MD5 f343834df5fd4482967041eb8fb93967
BLAKE2b-256 aef98c68341ac9f6f612682defcbc51ef1d04180a13cce41f21d92596e7de332

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27d39d697fdd7df1f2a32c1063756ee269ad8d5345c471ee3ca450636d56e8c6
MD5 264d54a4fd251bb102e7893cb6c54d76
BLAKE2b-256 cefec834eaa2cd9a8c277f963d8ff5351a4c478d81f6f14c970f1fc8e1e55d05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 0deb1d7226ea9da9b18881736d2d96accfa7f328c67b7410478cc064ad1fa6aa
MD5 c4d4ab8697d68821b7cfb3625ae95c9e
BLAKE2b-256 9ccb31358d6e6f53be90d75d5ce9fd9d3c9633827b363aefd5279775d4194c5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 ef20bf798ffe634090ad3dc2e8aa6a055f08c448810a2f800ab716cc18b80107
MD5 88220f595ca7354c53aa7d030fa8ec80
BLAKE2b-256 be35ee26a0b025d0af84d24cb4a1093e0acdeae1c150d8fc98cec9d7556b4d14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 8deba44fd563361c488dedec90dc330763ee0c01ba54e17df54ef5820079e7e0
MD5 e2d5b8114ff2346c04282c83c57075f8
BLAKE2b-256 5d1a3769a1da21236c06fbc300048c0da4157ee7523bbf82ebf53bd73412e3ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b3f15d5d033fd3dcb85d982d6828ddab94134686fac2c02c13a8822aa03e1321
MD5 f40b3d826373b5322021f3d6152cf0ec
BLAKE2b-256 d04dd29b94eca79cbb939b86235106a72135aaaed80ac987f90bc9cb52cf1e24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 059a380c08e849b6f312479b18cc63bba2808cff749ad71555f61dd930e3c9a2
MD5 9fee16a27e39c26bf21d88ada1004271
BLAKE2b-256 e9914d367732ff80666bd77c7de0eeebb7677ef33ec225449dae0a597e99d8ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ac1429be6d8bd3db0bf5becac3a38bd56f8421447790c50599cd90fd53417ec4
MD5 2f6105706d5ad1fedd972ed8d296c4b4
BLAKE2b-256 40bf7fad53f42418f03f254374b3bfd8e73cd2a974ac778677840c4ac1808adc

See more details on using hashes here.

File details

Details for the file ruff-0.0.254-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.254-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 688379050ae05394a6f9f9c8471587fd5dcf22149bd4304a4ede233cc4ef89a1
MD5 febd61c296d63ae59f9aa1beccb76e9d
BLAKE2b-256 108a12c4b8d9a600e3802148f3747cf0d3ef530da8748df0d79f73116f960a61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.254-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 dd58c500d039fb381af8d861ef456c3e94fd6855c3d267d6c6718c9a9fe07be0
MD5 7bd734d45918f27874efc41abd31b02b
BLAKE2b-256 eb1c4edb3c205ce3b1b3979bf4913cdba5872283ff013eabb5297c8e65d47535

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