Clarify some isort differences in FAQ (#3954)

This commit is contained in:
Charlie Marsh 2023-04-13 00:05:28 -04:00 committed by GitHub
parent e160a52bfd
commit d9ed43d112
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 3 deletions

View File

@ -196,11 +196,28 @@ project. See [#283](https://github.com/charliermarsh/ruff/issues/283) for more.
## How does Ruff's import sorting compare to [isort](https://pypi.org/project/isort/)? ## How does Ruff's import sorting compare to [isort](https://pypi.org/project/isort/)?
Ruff's import sorting is intended to be nearly equivalent to isort when used `profile = "black"`. Ruff's import sorting is intended to be near-equivalent to isort's when using isort's
There are a few known, minor differences in how Ruff and isort break ties between similar imports, `profile = "black"`.
and in how Ruff and isort treat inline comments in some cases (see: [#1381](https://github.com/charliermarsh/ruff/issues/1381),
There are a few known differences in how Ruff and isort treat aliased imports, and in how Ruff and
isort treat inline comments in some cases (see: [#1381](https://github.com/charliermarsh/ruff/issues/1381),
[#2104](https://github.com/charliermarsh/ruff/issues/2104)). [#2104](https://github.com/charliermarsh/ruff/issues/2104)).
For example, Ruff tends to group non-aliased imports from the same module:
```py
from numpy import cos, int8, int16, int32, int64, tan, uint8, uint16, uint32, uint64
from numpy import sin as np_sin
```
Whereas isort splits them into separate import statements at each aliased boundary:
```py
from numpy import cos, int8, int16, int32, int64
from numpy import sin as np_sin
from numpy import tan, uint8, uint16, uint32, uint64
```
Like isort, Ruff's import sorting is compatible with Black. Like isort, Ruff's import sorting is compatible with Black.
Ruff does not yet support all of isort's configuration options, though it does support many of Ruff does not yet support all of isort's configuration options, though it does support many of