Hai Vu
Hai Vu

Reputation: 40688

How do I isort using ruff?

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?

Upvotes: 17

Views: 16778

Answers (1)

Andrej Kesely
Andrej Kesely

Reputation: 195408

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 .

Upvotes: 34

Related Questions