Skip to content

Divergent isort I001 sort order #2604

Description

@moritz89

Ruff reports an error with the following code even though the imports were sorted with isort.

# test.py
from json import decoder
from json import encoder as j_encoder
from json import tool

jdec = decoder.JSONDecoder()
jenv = j_encoder.JSONEncoder()
tool.main()
ruff test.py --select I --isolated

test.py:1:1: I001 Import block is un-sorted or un-formatted
Found 1 error.
1 potentially fixable with the --fix option.

ruff --version
ruff 0.0.239

The order that ruff expects instead is:

# test.py
from json import decoder, tool
from json import encoder as j_encoder

jdec = decoder.JSONDecoder()
jenv = j_encoder.JSONEncoder()
tool.main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions