Skip to content

# isort: off does not honor import statements but does honor import from statements #2528

Closed

Description

@hunterhogan

Using the files in ufoLib2/tests,

Run

isort --skip-gitignore --check-only --diff tests

# isort: off not applied serde/test_json.py

Code snippet

import ufoLib2.objects


# isort: off
pytest.importorskip("cattrs")


import ufoLib2.serde.json  # noqa: E402

# isort: off not applied serde/test_msgpack.py

Code snippet

import ufoLib2.objects


# isort: off
pytest.importorskip("cattrs")
pytest.importorskip("msgpack")


import msgpack  # type: ignore  # noqa


import ufoLib2.serde.msgpack  # noqa: E402

# isort: off is applied test_converters.py

Code snippet

from ufoLib2.objects.info import (
    GaspBehavior,
    ...
    WoffMetadataVendor,
)


# isort: off
cattrs = pytest.importorskip("cattrs")
from ufoLib2.converters import register_hooks, structure, unstructure  # noqa: E402

~ ast.Import vs ast.ImportFrom

It seems that the command comment affects objects that would be parsed as ast.ImportFrom objects, but does not affect objects that would be parsed as ast.Import objects.

We stumbled across this while updating multiple files in this PR.

#2239 has some discussions about # isort: off, but I think it's a different issue.

Activity

  1. added theissue type on May 7, 2026
  2. added a commit that references this issue on May 18, 2026
    d4131a5
  3. DanielNoord commented on May 31, 2026

    @DanielNoord
    Member

    No clue why this attracted so many AI slop contributions. Anyway, fixed in #2553.

    Thanks for reporting :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions