PyCQA / isort

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

Unrecoverable exception thrown using --sort-reexports #2252

Open staceybellerose opened 8 months ago

staceybellerose commented 8 months ago

When using --sort-reexports, I get the following error. Without the flag, it works just fine. This is in isort version 5.13.2

$ isort -c --sort-reexports .
ERROR: Unrecoverable exception thrown when parsing ./widgets/__init__.py! This should NEVER happen.
If encountered, please open an issue: https://github.com/PyCQA/isort/issues/new
Traceback (most recent call last):
  File "xxx/venv/bin/isort", line 8, in <module>
    sys.exit(main())
  File "xxx/venv/lib/python3.9/site-packages/isort/main.py", line 1228, in main
    for sort_attempt in attempt_iterator:
  File "xxx/venv/lib/python3.9/site-packages/isort/main.py", line 1212, in <genexpr>
    sort_imports(  # type: ignore
  File "xxx/venv/lib/python3.9/site-packages/isort/main.py", line 87, in sort_imports
    incorrectly_sorted = not api.check_file(file_name, config=config, **kwargs)
  File "xxx/venv/lib/python3.9/site-packages/isort/api.py", line 338, in check_file
    return check_stream(
  File "xxx/venv/lib/python3.9/site-packages/isort/api.py", line 264, in check_stream
    changed: bool = sort_stream(
  File "xxx/venv/lib/python3.9/site-packages/isort/api.py", line 210, in sort_stream
    changed = core.process(
  File "xxx/venv/lib/python3.9/site-packages/isort/core.py", line 153, in process
    sort_section_pointer += output_stream.write(sorted_code)
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

The file in question is this.

from .dropdown import DropDown
from .meter import Meter
from .scalespinner import ScaleSpinner
from .tooltip import ToolTip
from .url_label import UrlLabel

__all__ = ["DropDown", "Meter", "ScaleSpinner", "ToolTip", "UrlLabel"]