Open webknjaz opened 1 month ago
I tried out all of the traceback frames and here's paths that trigger the circular import:
$ python -m mypy.report
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~/src/github/python/mypy/mypy/report.py", line 19, in <module>
from mypy import stats
File "~/src/github/python/mypy/mypy/stats.py", line 11, in <module>
from mypy.argmap import map_formals_to_actuals
File "~/src/github/python/mypy/mypy/argmap.py", line 8, in <module>
from mypy.maptype import map_instance_to_supertype
File "~/src/github/python/mypy/mypy/maptype.py", line 3, in <module>
from mypy.expandtype import expand_type_by_instance
File "~/src/github/python/mypy/mypy/expandtype.py", line 7, in <module>
from mypy.types import (
File "~/src/github/python/mypy/mypy/types.py", line 3751, in <module>
from mypy.expandtype import ExpandTypeVisitor
ImportError: cannot import name 'ExpandTypeVisitor' from partially initialized module 'mypy.expandtype' (most likely due to a circular import) (~/src/github/python/mypy/mypy/expandtype.py)
$ python -m mypy
usage: mypy [-h] [-v] [-V] [more options; see below]
[-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: Missing target module, package, files, or command.
$ python -m mypy.argmap
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~/src/github/python/mypy/mypy/argmap.py", line 8, in <module>
from mypy.maptype import map_instance_to_supertype
File "~/src/github/python/mypy/mypy/maptype.py", line 3, in <module>
from mypy.expandtype import expand_type_by_instance
File "~/src/github/python/mypy/mypy/expandtype.py", line 7, in <module>
from mypy.types import (
File "~/src/github/python/mypy/mypy/types.py", line 3751, in <module>
from mypy.expandtype import ExpandTypeVisitor
ImportError: cannot import name 'ExpandTypeVisitor' from partially initialized module 'mypy.expandtype' (most likely due to a circular import) (~/src/github/python/mypy/mypy/expandtype.py)
$ python -m mypy.maptype
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~/src/github/python/mypy/mypy/maptype.py", line 3, in <module>
from mypy.expandtype import expand_type_by_instance
File "~/src/github/python/mypy/mypy/expandtype.py", line 7, in <module>
from mypy.types import (
File "~/src/github/python/mypy/mypy/types.py", line 3751, in <module>
from mypy.expandtype import ExpandTypeVisitor
ImportError: cannot import name 'ExpandTypeVisitor' from partially initialized module 'mypy.expandtype' (most likely due to a circular import) (~/src/github/python/mypy/mypy/expandtype.py)
$ python -m mypy.expandtype
$ python -m mypy.types
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~/src/github/python/mypy/mypy/types.py", line 3178, in <module>
from mypy.type_visitor import (
File "~/src/github/python/mypy/mypy/type_visitor.py", line 21, in <module>
from mypy.types import (
File "~/src/github/python/mypy/mypy/types.py", line 3178, in <module>
from mypy.type_visitor import (
ImportError: cannot import name 'ALL_STRATEGY' from partially initialized module 'mypy.type_visitor' (most likely due to a circular import) (~/src/github/python/mypy/mypy/type_visitor.py)
The traceback was discovered by @x612skm while looking into #17689.
It might be good to adapt https://github.com/aio-libs/aiohttp/blob/a847b5f/tests/test_circular_imports.py to run in this repo and catch any future import loops.
Bug Report
Running the
testreports
module in isolation reveals a circular import similar to #15570.To Reproduce
Expected Behavior
It should collect the tests from the module.
Actual Behavior
Your Environment
master
mypy.ini
(and other config files): N/A