The Ruff Formatter – Python’s Fastest Formatter! : Mike

The Ruff Formatter – Python’s Fastest Formatter!
by: Mike
blow post content copied from  Mouse Vs Python
click here to view original post

The Ruff project was released about a year ago and stormed the Python world. Ruff is written in Rust, but lints Python super fast. You can read all about it in An Intro to Ruff.

This week, the Ruff formatted 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!

Getting Started

If you haven’t got Ruff already, you’ll need to install it.

pip install ruff

If you do already have Ruff, be sure to upgrade to latest so you can give the formatted version a try!

Formatting with Ruff

To format your code with Ruff, you need to run ruff format.

Here’s an example of formatting your current folder:

ruff format .

The official announcement for the Ruff formatter shows it formatting Django, Zulip and other Python projects in less than a second.

Ruff is Configurable

The Ruff formatter adds some configuration options that are absent from Black. Namely, you can tweak your preferred quote and indentation style:

quote-style = "single"
indent-style = "tab"

Wrapping Up

Ruff can now replace flake8, pyLint, Black, isort and more. Try out the Ruff formatter today! You’ll like it and it will speed up your development time too!

The post The Ruff Formatter – Python’s Fastest Formatter! appeared first on Mouse Vs Python.

October 25, 2023 at 07:04PM
Click here for more details...

The original post is available in Mouse Vs Python by Mike
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.