Skip to content

sort_reexports does not respect isort: skip #2569

Description

@BD103

Hi! I'm running isort 8.0.1 with Python 3.10.20. It appears that the sort re-exports (__all__) configuration does not recognize the # isort: skip action comment:

# reproduction.py

my_list = ["bee", "Albatross", "Dinosaur", "cat"]
__all__ = my_list # isort: skip
$ isort --sort-reexports reproduction.py 
ERROR: isort failed to parse the given literal __all__ = my_list # isort: skip
. It's important to note that isort literal sorting only supports simple literals parsable by ast.literal_eval which gave the exception of malformed node or string on line 1: <ast.Name object at 0x107927640>.

I expected isort to skip over the __all__ line and not give an error. I was able to work around the issue using # isort: off, but I would prefer to use # isort: skip if possible:

# workaround.py

my_list = ["bee", "Albatross", "Dinosaur", "cat"]
# isort: off
__all__ = my_list
# isort: on

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