Skip to content

Commit bf6b02d

Browse files
committed
Attempt to fix issue with ParamSpec serialization (#12654)
I've seen crashes like this, which might be caused by not fixing up some FakeInfos: ``` File "mypy/checkexpr.py", line 3981, in accept File "mypy/nodes.py", line 1753, in accept File "mypy/checkexpr.py", line 288, in visit_call_expr File "mypy/checkexpr.py", line 371, in visit_call_expr_inner File "mypy/checkexpr.py", line 880, in check_call_expr_with_callee_type File "mypy/checkexpr.py", line 940, in check_call File "mypy/checkexpr.py", line 1027, in check_callable_call File "mypy/checkexpr.py", line 1269, in infer_function_type_arguments File "mypy/checkexpr.py", line 1324, in infer_function_type_arguments_pass2 File "mypy/infer.py", line 47, in infer_function_type_arguments File "mypy/constraints.py", line 72, in infer_constraints_for_callable File "mypy/constraints.py", line 108, in infer_constraints File "mypy/constraints.py", line 181, in _infer_constraints File "mypy/types.py", line 1576, in accept File "mypy/constraints.py", line 663, in visit_callable_type File "mypy/constraints.py", line 685, in infer_against_overloaded File "mypy/constraints.py", line 775, in find_matching_overload_item File "mypy/subtypes.py", line 942, in is_callable_compatible File "mypy/subtypes.py", line 1209, in unify_generic_callable File "mypy/applytype.py", line 86, in apply_generic_arguments File "mypy/applytype.py", line 50, in get_target_type File "mypy/subtypes.py", line 97, in is_subtype File "mypy/subtypes.py", line 158, in _is_subtype File "mypy/types.py", line 615, in accept File "mypy/subtypes.py", line 341, in visit_param_spec File "mypy/subtypes.py", line 217, in _is_subtype File "mypy/subtypes.py", line 97, in is_subtype File "mypy/subtypes.py", line 158, in _is_subtype File "mypy/types.py", line 1127, in accept File "mypy/subtypes.py", line 257, in visit_instance AttributeError: attribute 'fallback_to_any' of 'TypeInfo' undefined ``` I don't have a small reproducer to I couldn't add a test case, unfortunately.
1 parent 1749cb7 commit bf6b02d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

mypy/fixup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ def visit_callable_type(self, ct: CallableType) -> None:
188188
if ct.ret_type is not None:
189189
ct.ret_type.accept(self)
190190
for v in ct.variables:
191-
if isinstance(v, TypeVarType):
192-
if v.values:
193-
for val in v.values:
194-
val.accept(self)
195-
v.upper_bound.accept(self)
191+
v.accept(self)
196192
for arg in ct.bound_args:
197193
if arg:
198194
arg.accept(self)
@@ -259,6 +255,8 @@ def visit_parameters(self, p: Parameters) -> None:
259255
for argt in p.arg_types:
260256
if argt is not None:
261257
argt.accept(self)
258+
for var in p.variables:
259+
var.accept(self)
262260

263261
def visit_unbound_type(self, o: UnboundType) -> None:
264262
for a in o.args:

0 commit comments

Comments
 (0)