Skip to main content

An extremely fast Python linter and code formatter, written in Rust.

Project description

Wruff

Repository | Upstream Docs

An extremely fast Python linter and code formatter, written in Rust.

Wruff Fork

This repository is developed as Wruff, a deliberate fork of Ruff with a different formatter opinion set. Wruff exists to keep Ruff's speed and general formatting approach while changing a few defaults and adding a small set of formatter controls that better match the style this fork is targeting.

Wruff currently differs from upstream Ruff in these user-visible ways:

  • Default line-length = 120
  • Default argument-indent = "double" for multiline function-definition parameters
  • Default slice-spacing = "permissive"
  • Default preserve-multiline = true
  • Additional hug-nested-calls option for compact outer wrappers around multiline nested calls
  • Accepts wruff.toml, .wruff.toml, and [tool.wruff], while still recognizing Ruff's config names

If you want Wruff's formatter behavior explicitly in config, use:

[tool.wruff]
line-length = 120

[tool.wruff.format]
argument-indent = "double"
slice-spacing = "permissive"
preserve-multiline = true

The rest of this README still largely describes upstream Ruff and its broader capabilities. Wruff inherits that foundation and then layers its fork-specific defaults and options on top. References to docs.astral.sh/ruff below point to the upstream documentation until Wruff has its own docs site.

Shows a bar chart with benchmark results.

Linting the CPython codebase from scratch.

  • ⚡️ 10-100x faster than existing linters (like Flake8) and formatters (like Black)
  • 🐍 Installable via pip
  • 🛠️ pyproject.toml support
  • 🤝 Python 3.14 compatibility
  • ⚖️ Drop-in parity with Flake8, isort, and Black
  • 📦 Built-in caching, to avoid re-analyzing unchanged files
  • 🔧 Fix support, for automatic error correction (e.g., automatically remove unused imports)
  • 📏 Over 800 built-in rules, with native re-implementations of popular 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), Black, isort, pydocstyle, pyupgrade, autoflake, and more, 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, the creators of uv and ty.

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 (also here):

This is just ridiculously fast... ruff is amazing.

Table of Contents

For more, see the upstream Ruff 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 upstream Ruff documentation.

Installation

Wruff is invoked as wruff.

From a local checkout, run Wruff directly with Cargo:

cargo run --bin wruff -- check   # Lint all files in the current directory.
cargo run --bin wruff -- format  # Format all files in the current directory.

Or build the binary once and run it directly:

cargo build --bin wruff
./target/debug/wruff check
./target/debug/wruff format

You can also install the local checkout in editable mode:

pip install -e .
wruff check
wruff format

Wruff does not yet publish separate standalone installers or fork-specific package-manager integrations. For inherited behavior and configuration details, see the upstream Ruff docs.

Usage

To run Wruff as a linter, try any of the following:

wruff check                          # Lint all files in the current directory (and any subdirectories).
wruff check path/to/code/            # Lint all files in `/path/to/code` (and any subdirectories).
wruff check path/to/code/*.py        # Lint all `.py` files in `/path/to/code`.
wruff check path/to/code/to/file.py  # Lint `file.py`.
wruff check @arguments.txt           # Lint using an input file, treating its contents as newline-delimited command-line arguments.

Or, to run Wruff as a formatter:

wruff format                          # Format all files in the current directory (and any subdirectories).
wruff format path/to/code/            # Format all files in `/path/to/code` (and any subdirectories).
wruff format path/to/code/*.py        # Format all `.py` files in `/path/to/code`.
wruff format path/to/code/to/file.py  # Format `file.py`.
wruff format @arguments.txt           # Format using an input file, treating its contents as newline-delimited command-line arguments.

Wruff can also be used as a pre-commit hook via local hooks:

- repo: local
  hooks:
    - id: wruff-check
      name: wruff check
      entry: wruff check --fix
      language: system
      types_or: [python, pyi]
    - id: wruff-format
      name: wruff format
      entry: wruff format
      language: system
      types_or: [python, pyi]

Wruff does not yet publish fork-specific editor or GitHub Action integrations. The upstream Ruff ecosystem can still be a useful reference, but those integrations are not Wruff-specific.

Configuration

Wruff can be configured through a pyproject.toml, wruff.toml, .wruff.toml, ruff.toml, or .ruff.toml file (see: Configuration, or Settings for a complete list of all configuration options).

If left unspecified, Wruff's default configuration is equivalent to the following wruff.toml file:

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".wruff_cache",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Wruff defaults to a wider line length.
line-length = 120
indent-width = 4

# Assume Python 3.10
target-version = "py310"

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[format]
# Wruff defaults to double-indented multiline function parameters.
argument-indent = "double"

# Wruff keeps compact spacing for common slice arithmetic and attributes.
slice-spacing = "permissive"

# Wruff preserves existing multiline joiners and parameter lists.
preserve-multiline = true

# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

Note that, in a pyproject.toml, each section header should be prefixed with tool.wruff. For example, [lint] should be replaced with [tool.wruff.lint]. For compatibility, Wruff also recognizes tool.ruff.

Some configuration options can be provided via dedicated command-line arguments, such as those related to rule enablement and disablement, file discovery, and logging level:

wruff check --select F401 --select F403 --quiet

The remaining configuration options can be provided through a catch-all --config argument:

wruff check --config "lint.per-file-ignores = {'some_file.py' = ['F841']}"

To opt in to the latest lint rules, formatter style changes, interface updates, and more, enable preview mode by setting preview = true in your configuration file or passing --preview on the command line. Preview mode enables a collection of unstable features that may change prior to stabilization.

See wruff help for more on Wruff's top-level commands, or wruff help check and wruff help format for more on the linting and formatting commands, respectively.

Rules

Ruff supports over 900 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 F rules, along with a subset of the E rules, omitting any stylistic rules that overlap with the use of a formatter, like wruff format or 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.

In preview, Ruff enables an expanded set of default rules that includes rules from the B, UP, and RUF categories, as well as many more. If you give the new defaults a try, feel free to leave feedback in the GitHub discussion, where you can also find the new rule set listed in full.

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.

For behavior inherited from Ruff, the upstream documentation at docs.astral.sh/ruff is still the best reference.

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 formatter is built on a fork of Rome's rome_formatter, and again draws on both API and implementation details from Rome, Prettier, and Black.

Ruff's import resolver is based on the import resolution algorithm from Pyright.

Ruff is also influenced by a number of tools outside the Python ecosystem, like Clippy and ESLint.

Wruff builds on Ruff, which 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:

Show Your Support

If you're using Wruff, consider adding the Wruff badge to your project's README.md:

[![Wruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/rwightman/wruff/main/assets/badge/v2.json)](https://github.com/rwightman/wruff)

...or README.rst:

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/rwightman/wruff/main/assets/badge/v2.json
    :target: https://github.com/rwightman/wruff
    :alt: Wruff

...or, as HTML:

<a href="https://github.com/rwightman/wruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/rwightman/wruff/main/assets/badge/v2.json" alt="Wruff" style="max-width:100%;"></a>

License

This repository is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wruff-0.15.10.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wruff-0.15.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

File details

Details for the file wruff-0.15.10.tar.gz.

File metadata

  • Download URL: wruff-0.15.10.tar.gz
  • Upload date:
  • Size: 4.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for wruff-0.15.10.tar.gz
Algorithm Hash digest
SHA256 c1eaead0a7d37f4dbd3cb7b8b5e3b261f7d665299da0b9a7c917061807cc3f07
MD5 81e3a6b1552c00dc88700809d6922b45
BLAKE2b-256 28f5d1eb1f8de06e7a3d4dbd7d91c645581a6a0452daa9b995e879a6b97475c8

See more details on using hashes here.

File details

Details for the file wruff-0.15.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wruff-0.15.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e80eaf8066de40d8eca4336d883cf06792a9d74e756115a02ec04968fd80c12
MD5 cf0775e09d9221a3a82a24bf4d9db891
BLAKE2b-256 262310516ed264fa231021f170932654f1e13f9bd45815d48cdc41b8378ebbed

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