Potential inconsistency between Ruff's I
and isort · Issue #2104 · astral-sh/ruff (original) (raw)
I believe this is distinct from #1718; cross-linking in case there are similarities, though.
isort version: 5.11.4
Ruff version: 230
isort config:
[tool.isort] line_length = 95 profile = "black" remove_redundant_aliases = true
Commands:
(sphinx) PS I:\Development\sphinx> ruff -V
ruff 0.0.230
(sphinx) PS I:\Development\sphinx> type bug.py
from operator import add # NoQA: F401
from operator import mul, sub
(sphinx) PS I:\Development\sphinx> ruff --isolated --select I bug.py
bug.py:1:1: I001 Import block is un-sorted or un-formatted
Found 1 error(s).
1 potentially fixable with the --fix option.
(sphinx) PS I:\Development\sphinx> isort --check bug.py
Note Ruff wants to re-format to:
from operator import ( add, # NoQA: F401 mul, sub, )
whereas isort
wants to reformat to:
from operator import add # NoQA: F401 from operator import mul, sub
This appeared in the Sphinx project where some imports are type-comment only (e.g. in giving type annotations to iterators, where the pattern is for item in items: # type: blah`, should MyPy not be able to deduce the type of
item``).
A