Skip to main content

An extremely fast Python linter, written in Rust.

Reason this release was yanked:

Issue with importing Ruff as a module

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.

Ruff is backed by Astral. Read the launch post, or the original project announcement.

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.266'
  hooks:
    - id: ruff

Ruff can also be used as a VS Code extension or alongside any other editor through the Ruff LSP.

Ruff can also be used as a GitHub Action via ruff-action:

name: Ruff
on: [ push, pull_request ]
jobs:
  ruff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: chartboost/ruff-action@v1

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", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".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 by a number of major open-source projects and companies, 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.266.tar.gz (1.1 MB 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.266-py3-none-win_arm64.whl (5.3 MB view details)

Uploaded Python 3Windows ARM64

ruff-0.0.266-py3-none-win_amd64.whl (5.5 MB view details)

Uploaded Python 3Windows x86-64

ruff-0.0.266-py3-none-win32.whl (5.1 MB view details)

Uploaded Python 3Windows x86

ruff-0.0.266-py3-none-musllinux_1_2_x86_64.whl (5.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ruff-0.0.266-py3-none-musllinux_1_2_i686.whl (5.2 MB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

ruff-0.0.266-py3-none-musllinux_1_2_armv7l.whl (4.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

ruff-0.0.266-py3-none-musllinux_1_2_aarch64.whl (5.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ruff-0.0.266-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ruff-0.0.266-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (6.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

ruff-0.0.266-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (5.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

ruff-0.0.266-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (5.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64

ruff-0.0.266-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

ruff-0.0.266-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (4.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ruff-0.0.266-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ruff-0.0.266-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (10.1 MB view details)

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

ruff-0.0.266-py3-none-macosx_10_7_x86_64.whl (5.3 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: ruff-0.0.266.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for ruff-0.0.266.tar.gz
Algorithm Hash digest
SHA256 7ad7b69b40e009aa96551971bea740bf2332c1739085cf7a79fee6ef11105d29
MD5 ac24df5fa6cebf57a32ec2c8fada2cba
BLAKE2b-256 634cc66d7bc8dbb54f91b9448311020382b716932551d03832365c6aa8679801

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.266-py3-none-win_arm64.whl
  • Upload date:
  • Size: 5.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.266-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 a53dc7d99937305519072e390714fab9d6ccffc57c1f04e81eb95d6549c333df
MD5 4c17d2df94777b8e795fedbb31cc2d21
BLAKE2b-256 268e31206c255790393cd614165615b33a537824b9295770ee6980f3b6e89d67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.266-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.5 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.266-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 fbc094bc88893e43b506343b7643f46d0ee58b8726cb0521cf72caa95730cfe1
MD5 1ef3238dd68c73c2c617b3ea24d9659f
BLAKE2b-256 65964ae46a3b648e01e28c8fc37270570bcebc09e9f995e82e909596149e2104

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.266-py3-none-win32.whl
  • Upload date:
  • Size: 5.1 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.266-py3-none-win32.whl
Algorithm Hash digest
SHA256 75b6c78a1b9d4eb4146a110949a9530f788438b813351bddcdcf373e46b33910
MD5 5f21e3b41dcd4a4b40c83fb7e58e99c4
BLAKE2b-256 e3b6a20baeab323de1ffae0ffe73848344719a23e215360f3d0e0c285434186c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c543bcf4d55f244816e00811dc3a00a122ba14cc0c0ba636dbaf3a765eaeba81
MD5 3f2c35b0bff1a677157e733b103c863d
BLAKE2b-256 874c2a70889c4bcc4b4527196544973986160eb126de927bd43db92ed8644812

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruff-0.0.266-py3-none-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 5.2 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.266-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 8a80b5641572c76a77be69d063ee7b408b1aa9ef583b97862a1d8b2dfac41a15
MD5 87126df662539b38a84be4fc69b404f4
BLAKE2b-256 37de09668e68d82252ca4771108d1b142422d170ae4a7d63f4a1a08f79387fba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 1c9d52820a4744e9cfb4bc2492c8ecd6329147366a7e86cf198c0b2f7f4532af
MD5 14b40cb28cb0c73ec199afc2059f0af9
BLAKE2b-256 2ece00adeb1b334a2de48f73fab18a83b723c16abac7d48b58290da11dc6e6b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e9a89114336a2d2ad5fd237381dfbaf1d8e7e8b34f01eba283549e3e8802f6f8
MD5 49c4e394df159c98e947c298459fbc29
BLAKE2b-256 25c250271704c7b99e3abab4ca2e9c12c8211e96dec5e1dafb0a29c3ebfc7316

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 422da2da16fd1a38f9731c2f54320e2550a1ae51f9f494b6c11002acd8b53b43
MD5 a23e68e86349783ee9228c0b3485c796
BLAKE2b-256 ca6a16b7fbd576b365c4a8b9a7a3645027ba1d42c559936cad1bb5710335cb25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 6722812b8a5e5ca57f20983dfa4eed4b379ce2c5648e8a4462c43dc90a6f7ab0
MD5 dace79637c38b52e312907a96a217e2a
BLAKE2b-256 52bb77371126d80b0c71d6b99476d2d799b618c3c6a9399d06d8ee7d099161a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 a358e036c6c797c32986e2c6a1dc258a83439c8283c4520d029e505a4d2fd9a1
MD5 cbadd0dcc34fc23fbfa29978a697a17e
BLAKE2b-256 6aef690589b772159e72e954a97521cfdb488723737887b39e7569f2e02b29bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 784cb211de2a67a1374e9936db9de8923c922e64efc5f4ddc37511dd464459a1
MD5 153957866cb1b76030b50b04f24a09af
BLAKE2b-256 b617a00663e76f9716c4023f7ceb03e4f49991bcc54735c9b3987848375a3782

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8afe32e66ecd18f7f169587ea86260ce0666a026c83370dc50ba2a7eca8acd40
MD5 362c8d18361f9fd87a2b763613807f04
BLAKE2b-256 9a8946c177fce922963a6a78d86f3db1b563fcb44482e740035c082ca63daed4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 94304a0c65219e5156caa0846b2b9dd35eb508aa79f470a7a4a6363681a6ee0a
MD5 dcd13712ee4d1e1756c17d471463f25b
BLAKE2b-256 fa884d1a38d7f4bc65ec963be827190bb2e85d047d1d013077ce2deab41ced56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 86d931303fb5c43945ab5774d53a28167f4c9b40712553b52329f16a79e9ff10
MD5 f21e817841062ff480443b360cfa5a66
BLAKE2b-256 d839df8222f0033747d1d83102d22968d297ba0fb514eb8987a8755b27842e0f

See more details on using hashes here.

File details

Details for the file ruff-0.0.266-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.266-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 5a80e6279d2af09d0827804356c6c73b0f47b9ee116dfd0a225aa2a203839a17
MD5 134a6033e7e2e992e31e6a9810e09b83
BLAKE2b-256 598f20ef6e87f7dcfb339f14befaf36069d558bda5a71c3beaba2b6b4a222af6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruff-0.0.266-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ff892ed9108ee888c6a8f2b8efec47c40dd7dac1977d575e2b4d69ef9363af25
MD5 f20f527f7931ca04b74884293e73c563
BLAKE2b-256 47f48a5b9ad75b004d19ed0ea8ac2f6a2467a38a883edf10929c726a129c7733

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