Skip to content

Commit ee9bd9d

Browse files
committed
make 101 % sure that inferred_types is defined before used
1 parent 16c768f commit ee9bd9d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mypy/checkexpr.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,6 +2719,7 @@ def check_overload_call(
27192719
# for example, when we have a fallback alternative that accepts an unrestricted
27202720
# typevar. See https://github.com/python/mypy/issues/4063 for related discussion.
27212721
erased_targets: list[CallableType] | None = None
2722+
inferred_types: list[Type] | None = None
27222723
unioned_result: tuple[Type, Type] | None = None
27232724

27242725
# Determine whether we need to encourage union math. This should be generally safe,
@@ -2780,9 +2781,10 @@ def check_overload_call(
27802781
else:
27812782
inferred_result = None
27822783
if unioned_result is not None:
2783-
for inferred_type in inferred_types:
2784-
if isinstance(c := get_proper_type(inferred_type), CallableType):
2785-
self.chk.warn_deprecated(c.definition, context)
2784+
if inferred_types is not None:
2785+
for inferred_type in inferred_types:
2786+
if isinstance(c := get_proper_type(inferred_type), CallableType):
2787+
self.chk.warn_deprecated(c.definition, context)
27862788
return unioned_result
27872789
if inferred_result is not None:
27882790
if isinstance(c := get_proper_type(inferred_result[1]), CallableType):

0 commit comments

Comments
 (0)