Ruff: Python Linting with Rust

Stu Burgoyne
4 min readFeb 18, 2024

What is Ruff?

In short, it’s an extremely fast Python linter.

It fits into same category as flake8and pyflakes. A static analysis tool that tries to identify issues with your code.

In addition to being a linter, it can also auto fix and transform code.

This aims to speed up development whilst spending less time worrying about code standardisation.

Ruff was loosely modelled on flake8and it’s standards. Then over time included re-writes of existing tools like pysort, pydocstyle and pyupdateamongst others.

Ok…but how do I use it..?

First step is to install ruff, I’m going to use pip as my package installer here but similiar can be done with poetry and easyinstall (See respective docs for details).

pip install ruff

To validate the install ran successfully:

ruff -V

The output should be equivalent to ruff X.X.X where X is a major, minor or patch version number.

First obvious step after installing is to just simply run Ruff against your code base. You can achieve this using the following command from a terminal in the root directory of your project:

ruff check .

--

--