pythonisortruff

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?


Solution

  • 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 .