Skip to content

I001 does not use human sort. #1371

@ghuls

Description

@ghuls

I001 does not use human sort like isort.

I001 also does not indicate the lines on which it finds the problem, but always mentions the first line of the file even if the first x lines are correctly sorted.

# Output as generated by: isort --profile=black /tmp/human_sort_import.py
$ ❯ cat /tmp/human_sort_import.py
from numpy import (
    cos,
    int8,
    int16,
    int32,
    int64,
    sin,
    tan,
    uint8,
    uint16,
    uint32,
    uint64,
)
$ ruff --select I001 --ignore F401  --no-cache /tmp/human_sort_import.py 
/tmp/human_sort_import.py:1:1: I001 Import block is un-sorted or un-formatted
Found 1 error(s).
1 potentially fixable with the --fix option.

$ cp -a /tmp/human_sort_import.py /tmp/human_sort_import.fixed.py

$ ruff --select I001 --ignore F401 --no-cache --fix /tmp/human_sort_import.fixed.py 
Found 1 error(s) (1 fixed, 0 remaining).

$ diff -u /tmp/human_sort_import.py /tmp/human_sort_import.fixed.py
--- /tmp/human_sort_import.py	2022-12-25 11:06:19.072930208 +0100
+++ /tmp/human_sort_import.fixed.py	2022-12-25 11:17:51.707302881 +0100
@@ -1,13 +1,13 @@
 from numpy import (
     cos,
-    int8,
     int16,
     int32,
     int64,
+    int8,
     sin,
     tan,
-    uint8,
     uint16,
     uint32,
     uint64,
+    uint8,
 )

$ isort --profile=black /tmp/human_sort_import.fixed.py
Fixing /tmp/human_sort_import.fixed.py

$ diff -u /tmp/human_sort_import.py /tmp/human_sort_import.fixed.py

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingisortRelated to import sorting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions