-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another circular import in mypy/test/testreports.py
#17726
Labels
bug
mypy got something wrong
Comments
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) |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Running the
testreports
module in isolation reveals a circular import similar to #15570.To Reproduce
$ tox r -e py311 -- mypy/test/testreports.py
Expected Behavior
It should collect the tests from the module.
Actual Behavior
Your Environment
master
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: