Discrepancies between isort and Ruff's I lint check · Issue #1718 · astral-sh/ruff (original) (raw)

It seems Ruff expects a space after isort:skip (i.e. Ruff wants isort: skip), and Ruff seems to ignore F401 for the purposes of import sorting, whereas isort honours them as skip markers(?).

Ruff also reports 1 error in the initial call, yet the --diff call reports three errors.

Ruff version 213; isort version 5.11.4

Sample file:

(sphinx) PS I:\Development\sphinx> type bug.py
from operator import add # noqa: F401 from operator import sub # noqa: F401

from math import pi # noqa: F401 isort:skip from math import e # noqa: F401 isort:skip

from string import ( # noqa: E402 # isort:skip ascii_lowercase )

from pprint import pprint # isort:skip (sphinx) PS I:\Development\sphinx> isort bug.py
(sphinx) PS I:\Development\sphinx> ruff bug.py --select I 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> ruff bug.py --diff
--- bug.py +++ bug.py @@ -1,11 +1,8 @@ -from operator import add # noqa: F401 -from operator import sub # noqa: F401

-from math import pi # noqa: F401 isort:skip -from math import e # noqa: F401 isort:skip

-from string import ( # noqa: E402 # isort:skip - ascii_lowercase +from math import ( + e, # noqa: F401 isort:skip + pi, # noqa: F401 isort:skip +) +from operator import ( + add, # noqa: F401 + sub, # noqa: F401 )

-from pprint import pprint # isort:skip

Would fix 3 error(s). (sphinx) PS I:\Development\sphinx> ruff -V
ruff 0.0.213 (sphinx) PS I:\Development\sphinx>

A