PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.53k stars 583 forks source link

--sort-reexports results in isort not being able to parse file #2286

Open mzmm1000 opened 2 months ago

mzmm1000 commented 2 months ago

Python version 3.12 isort version: 5.13.2

Test file test.py:

#!/usr/bin/env python
import importlib.metadata

__all__ = [
    "FooType",
    "BarType",
    "some_method",
]
__version__ = importlib.metadata.version("my-package")

Calling isort --srx test.py results in:

isort/main.py:105: UserWarning: Unable to parse file test.py due to too many values to unpack (expected 2)

The exception is actually triggered here - somehow, both assignments to __all__ and __version__ end up in code.

It works if an empty line between both assignments is introduced (or any other code, for that matter).