The Ruff project was released about a year ago and stormed the Python world. Ruff is written in Rust, but lints Python superfast.
This week, the Ruff formatter was released! You can still use Ruff to lint your Python code, but now you can also use Ruff to format your code with 99.9% Black compatibility. The good news? It’s over 30x faster than Black!
Ruff was released in the past year and has been gaining a lot of popularity. Ruff’s claim to fame is that it is fast because it was written in Rust! Ruff is 10-100x faster than existing linters!
You can install Ruff using pip:
pip install ruff
If you are on Mac or Linux and you use Brew, you can use that too:
brew install ruff
Ruff is also installable with conda:
conda install -c conda-forge ruff
Or if you have an existing project based on Poetry:
poetry add ruff
Now that you have Ruff installed, let’s look at a few examples of running Ruff on your code base!
Here are some examples from the Ruff docs:
# Lint all files in the current directory (and any subdirectories) ruff check . # Lint all files in `/path/to/code` (and any subdirectories) ruff check path/to/code/ # Lint all `.py` files in `/path/to/code` ruff check path/to/code/*.py # Lint `file.py` ruff check path/to/code/to/file.py
Ruff also supports a handy mode to watch for changes on a folder and re-run when a change is detected.
Here is the command you can use for that:
ruff check path/to/code/ --watch
Ruff combines functionality from flake8, pyLint, Black, isort into one neat library. Try out the Ruff formatter today! We believe you’ll like it, and it will shorten your development and build times too!