You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ autoimport repro.py
Traceback (most recent call last):
File "/home/homestar/tmp/.direnv/python-3.11.3/bin/autoimport", line 8, in <module>
sys.exit(cli())
^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/autoimport/entrypoints/cli.py", line 94, in cli
fixed_code = services.fix_files(flattened_files, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/autoimport/services.py", line 29, in fix_files
fixed_source = fix_code(source, config)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/autoimport/services.py", line 73, in fix_code
return SourceCode(original_source_code, config=config).fix()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/autoimport/model.py", line 67, in fix
self._fix_flake_import_errors()
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/autoimport/model.py", line 308, in _fix_flake_import_errors
self._remove_unused_imports(import_name)
File "/home/homestar/tmp/.direnv/python-3.11.3/lib/python3.11/site-packages/autoimport/model.py", line 455, in _remove_unused_imports
if re.match(
^^^^^^^^^
File "/home/homestar/.pyenv/versions/3.11.3/lib/python3.11/re/__init__.py", line 166, in match
return _compile(pattern, flags).match(string)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/.pyenv/versions/3.11.3/lib/python3.11/re/__init__.py", line 294, in _compile
p = _compiler.compile(pattern, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/.pyenv/versions/3.11.3/lib/python3.11/re/_compiler.py", line 743, in compile
p = _parser.parse(p, flags)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/.pyenv/versions/3.11.3/lib/python3.11/re/_parser.py", line 980, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/.pyenv/versions/3.11.3/lib/python3.11/re/_parser.py", line 455, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homestar/.pyenv/versions/3.11.3/lib/python3.11/re/_parser.py", line 685, in _parse
raise source.error("multiple repeat",
re.error: multiple repeat at position 37
It seems to be an issue with one of Autoimport's regex patterns. The error only occurs if both the star import and the if TYPE_CHECKING block are present. (Edit: see my comment below)
Description
I've stumbled upon a bug that comes up when using the
TYPE_CHECKING
guard together with a star import.Steps to reproduce
Here's a minimal reproducible example:
Click here to see the traceback
It seems to be an issue with one of Autoimport's regex patterns.
The error only occurs if both the star import and the(Edit: see my comment below)if TYPE_CHECKING
block are present.Environment
The text was updated successfully, but these errors were encountered: