How do I isort using ruff?

255 Views Asked by At

I often work in very small projects which do not have config file. How do I use ruff in place of isort to sort the imports? I know that the following command is roughly equivalent to black:

ruff format .

The format command do not sort the imports. How do I do that?

1

There are 1 best solutions below

0
Andrej Kesely On BEST ANSWER

According to the documentation:

Currently, the Ruff formatter does not sort imports. In order to both sort imports and format, call the Ruff linter and then the formatter:

ruff check --select I --fix .
ruff format .