Hello,
I got ERROR: Unrecoverable exception thrown when parsing ./aaa/bbb/ccc.py! This should NEVER happen.
$ python --version
Python 3.11.4
$ isort --version
_ _
(_) ___ ___ _ __| |_
| |/ _/ / _ \/ '__ _/
| |\__ \/\_\/| | | |_
|_|\___/\___/\_/ \_/
isort your imports, so you don't have to.
VERSION 5.12.0
$ cat /etc/debian_version
trixie/sid
$ tree
.
└── aaa
└── bbb
└── ccc.py
Content of the offending file:
$ cat aaa/bbb/ccc.py
from ..import bbb
My file is valid (or I just found a Python bug):
$ python -m aaa.bbb.ccc
$
But isort fails:
$ isort .
ERROR: Unrecoverable exception thrown when parsing ./aaa/bbb/ccc.py! This should NEVER happen.
If encountered, please open an issue: https://github.com/PyCQA/isort/issues/new
Traceback (most recent call last):
File "/home/louis/.virtualenvs/311/bin/isort", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/main.py", line 1226, in main
for sort_attempt in attempt_iterator:
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/main.py", line 1210, in <genexpr>
sort_imports( # type: ignore
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/main.py", line 93, in sort_imports
incorrectly_sorted = not api.sort_file(
^^^^^^^^^^^^^^
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/api.py", line 429, in sort_file
changed = sort_stream(
^^^^^^^^^^^^
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/api.py", line 210, in sort_stream
changed = core.process(
^^^^^^^^^^^^^
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/core.py", line 422, in process
parsed_content = parse.file_contents(import_section, config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/louis/.virtualenvs/311/lib/python3.11/site-packages/isort/parse.py", line 522, in file_contents
if "," in import_string.split(just_imports[-1])[-1]:
~~~~~~~~~~~~^^^^
IndexError: list index out of range
Everything works if I replace from ..import bbb with from .. import bbb (notice the space that was added/removed between .. and import).
Thanks for your work!
-- Louis
Hello,
I got
ERROR: Unrecoverable exception thrown when parsing ./aaa/bbb/ccc.py! This should NEVER happen.$ python --version Python 3.11.4 $ isort --version _ _ (_) ___ ___ _ __| |_ | |/ _/ / _ \/ '__ _/ | |\__ \/\_\/| | | |_ |_|\___/\___/\_/ \_/ isort your imports, so you don't have to. VERSION 5.12.0 $ cat /etc/debian_version trixie/sid $ tree . └── aaa └── bbb └── ccc.pyContent of the offending file:
My file is valid (or I just found a Python bug):
But isort fails:
Everything works if I replace
from ..import bbbwithfrom .. import bbb(notice the space that was added/removed between..andimport).Thanks for your work!
-- Louis