Closed
Description
With pydantic_core
installed, the following file:
from typing import Callable
from pydantic_core import core_schema
Recurse = Callable[[core_schema.CoreSchema, 'Walk'], core_schema.CoreSchema]
Walk = Callable[[core_schema.CoreSchema, Recurse], core_schema.CoreSchema]
Results in a segmentation fault on compiled version.
The end of the traceback using interpreted from master
:
...
File "/fakepath/lib/python3.12/site-packages/mypy/typetraverser.py", line 85, in visit_callable_type
self.traverse_types(t.arg_types)
File "/fakepath/lib/python3.12/site-packages/mypy/typetraverser.py", line 148, in traverse_types
typ.accept(self)
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 410, in accept
return visitor.visit_type_alias_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/messages.py", line 2754, in visit_type_alias_type
get_proper_type(t).accept(self)
^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 3185, in get_proper_type
typ = typ._expand_once()
^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 352, in _expand_once
new_tp = self.alias.target.accept(InstantiateAliasVisitor(mapping))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 2018, in accept
return visitor.visit_callable_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/expandtype.py", line 409, in visit_callable_type
arg_types = self.expand_types(t.arg_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/expandtype.py", line 515, in expand_types
a.append(t.accept(self))
^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 410, in accept
return visitor.visit_type_alias_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/expandtype.py", line 510, in visit_type_alias_type
return t.copy_modified(args=args)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 443, in copy_modified
return TypeAliasType(
^^^^^^^^^^^^^^
File "/fakepath/lib/python3.12/site-packages/mypy/types.py", line 318, in __init__
RecursionError: maximum recursion depth exceeded
Your Environment
- Mypy version used: 1.11.0 through 1.12.0
- Python version used: 3.12
- Mypy command:
mypy t.py --config-file mypy.ini
- Operating system and version: Ubuntu
Config file (the two config values are necessary to reproduce):
[mypy]
disallow_any_unimported = True
[mypy-pydantic_core.*]
follow_imports = skip