Closed
Description
Crash Report
I've been trying to annotate some decorators using ParamSpec
/Concatenate
and got mypy to segfault. In particular was trying to improve type annotations for https://github.com/python/typeshed/blob/main/stubs/decorator/decorator.pyi -- currently they are a bit too generic
Traceback
No traceback on latest stable mypy, just segfault
If I use master
on mypy playground I get INTERNAL_ERROR and this:
...
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/expandtype.py", line 536, in expand_types
a.append(t.accept(self))
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/types.py", line 1917, in accept
return visitor.visit_callable_type(self)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/expandtype.py", line 429, in visit_callable_type
arg_types = self.expand_types(t.arg_types)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/expandtype.py", line 536, in expand_types
a.append(t.accept(self))
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/types.py", line 1917, in accept
return visitor.visit_callable_type(self)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/expandtype.py", line 382, in visit_callable_type
param_spec = t.param_spec()
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/types.py", line 2035, in param_spec
prefix = Parameters(self.arg_types[:-2], self.arg_kinds[:-2], self.arg_names[:-2])
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/types.py", line 1569, in __init__
super().__init__(line, column)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/mypy/types.py", line 225, in __init__
super().__init__(line, column)
RecursionError: maximum recursion depth exceeded while calling a Python object
To Reproduce
Reproduces in https://mypy-play.net/?mypy=master&python=3.11&flags=show-traceback
from typing import ParamSpec, Concatenate, TypeVar, Callable
TD = TypeVar('TD')
PD = ParamSpec('PD')
def wrapper(
caller: Callable[Concatenate[Callable[PD, TD], PD], TD]
) -> None:
return None
T = TypeVar('T')
P = ParamSpec('P')
def _wrapped(func: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
return func(*args, **kwargs)
_wrapped = wrapper(_wrapped)
Your Environment
Segfaults on latest stable mypy (1.3.0
) regardless python version (tried 3.10/3.11/3.12)
INTERNAL_ERROR
on master
mypy