@@ -2746,7 +2746,8 @@ def check_overload_call(
27462746 # Record if we succeeded. Next we need to see if maybe normal procedure
27472747 # gives a narrower type.
27482748 if unioned_return :
2749- returns , inferred_types = zip (* unioned_return )
2749+ returns = tuple (u [0 ] for u in unioned_return )
2750+ inferred_types = tuple (u [1 ] for u in unioned_return )
27502751 # Note that we use `combine_function_signatures` instead of just returning
27512752 # a union of inferred callables because for example a call
27522753 # Union[int -> int, str -> str](Union[int, str]) is invalid and
@@ -2767,19 +2768,25 @@ def check_overload_call(
27672768 object_type ,
27682769 context ,
27692770 )
2770- # If any of checks succeed, stop early.
2771+ # If any of checks succeed, perform deprecation tests and stop early.
27712772 if inferred_result is not None and unioned_result is not None :
27722773 # Both unioned and direct checks succeeded, choose the more precise type.
27732774 if (
27742775 is_subtype (inferred_result [0 ], unioned_result [0 ])
27752776 and not isinstance (get_proper_type (inferred_result [0 ]), AnyType )
27762777 and not none_type_var_overlap
27772778 ):
2778- return inferred_result
2779- return unioned_result
2780- elif unioned_result is not None :
2779+ unioned_result = None
2780+ else :
2781+ inferred_result = None
2782+ 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 )
27812786 return unioned_result
2782- elif inferred_result is not None :
2787+ if inferred_result is not None :
2788+ if isinstance (c := get_proper_type (inferred_result [1 ]), CallableType ):
2789+ self .chk .warn_deprecated (c .definition , context )
27832790 return inferred_result
27842791
27852792 # Step 4: Failure. At this point, we know there is no match. We fall back to trying
0 commit comments