2023-10

2023-10-24 The Ruff Formatter

TL;DR

TL;DR: The Ruff formatter is an extremely fast Python formatter, written in Rust. It’s over 30x faster than Black and 100x faster than YAPF, formatting large-scale Python projects in milliseconds — all while achieving >99.9% Black compatibility.

A little over a year ago, I made the first commit to Ruff, an extremely fast Python linter, written in Rust.

Since then, Ruff has grown to millions of downloads per week with support for hundreds of lint rules, serving as a drop-in replacement for dozens of tools like Flake8, isort, and pyupgrade.

Today marks our biggest release since the linter itself: Ruff’s Python formatter, available now in Beta with pip install ruff and ruff format.

Astral doc

The Ruff formatter is an extremely fast Python code formatter designed as a drop-in replacement for Black, available as part of the ruff CLI (as of Ruff v0.0.289).

ruff format#

ruff format is the primary entrypoint to the formatter. It accepts a list of files or directories, and formats all discovered Python files:

ruff format .                 # Format all files in the current directory.
ruff format /path/to/file.py  # Format a single file.

Similar to Black, running ruff format /path/to/file.py will format the given file or directory in-place, while ruff format –check /path/to/file.py will avoid writing any formatted files back, and instead exit with a non-zero status code upon detecting any unformatted files.

For the full list of supported options, run ruff format –help.

2023-10-01 Découverte de rip (Solve and install Python packages quickly with rip (pip in Rust)

RIP: Fast, barebones pip implementation in Rust.

RIP is a library that allows the resolving and installing of Python PyPI packages from Rust into a virtual environment.

It’s based on our experience with building Rattler and aims to provide the same experience but for PyPI instead of Conda.

It should be fast and easy to use.

Like Rattler, this library is not a package manager itself but provides the low-level plumbing to be used in one.

RIP is based on the quite excellent work of posy and we have tried to credit the authors where possible.

Solver

We have integrated the stand-alone packaging SAT solver Resolvo , to resolve pypi packages.

This solver is incremental and adds packaging metadata during resolution of the SAT problem.

This feature can be enabled with the resolvo feature flag.