@@ -4706,15 +4706,8 @@ def infer_rvalue_with_fallback_context(
47064706 # There are two cases where we want to try re-inferring r.h.s. in a fallback
47074707 # type context. First case is when redefinitions are allowed, and we got
47084708 # invalid type when using the preferred (empty) type context.
4709- redefinition_fallback = (
4710- inferred is not None
4711- and not inferred .is_argument
4712- and not is_valid_inferred_type (rvalue_type , self .options )
4713- )
4714- # For function arguments the preference order is opposite, and we use errors
4715- # during type-checking as the fallback trigger.
4716- argument_redefinition_fallback = (
4717- inferred is not None and inferred .is_argument and local_errors .has_new_errors ()
4709+ redefinition_fallback = inferred is not None and not is_valid_inferred_type (
4710+ rvalue_type , self .options
47184711 )
47194712 # Try re-inferring r.h.s. in empty context for union with explicit annotation,
47204713 # and use it results in a narrower type. This helps with various practical
@@ -4726,7 +4719,7 @@ def infer_rvalue_with_fallback_context(
47264719 )
47274720
47284721 # Skip literal types, as they have special logic (for better errors).
4729- try_fallback = redefinition_fallback or union_fallback or argument_redefinition_fallback
4722+ try_fallback = redefinition_fallback or union_fallback
47304723 if try_fallback and not is_literal_type_like (rvalue_type ):
47314724 with (
47324725 self .msg .filter_errors (save_filtered_errors = True ) as alt_local_errors ,
@@ -4741,7 +4734,6 @@ def infer_rvalue_with_fallback_context(
47414734 and (
47424735 # For redefinition fallback we are fine getting not a subtype.
47434736 redefinition_fallback
4744- or argument_redefinition_fallback
47454737 # Skip Any type, since it is special cased in binder.
47464738 or not isinstance (get_proper_type (alt_rvalue_type ), AnyType )
47474739 and is_proper_subtype (alt_rvalue_type , rvalue_type )
@@ -4790,9 +4782,7 @@ def check_simple_assignment(
47904782 rvalue , type_context = lvalue_type , always_allow_any = always_allow_any
47914783 )
47924784 else :
4793- # Prefer full type context for function arguments as this reduces
4794- # false positives, see issue #19918 for discussion.
4795- if inferred is not None and not inferred .is_argument :
4785+ if inferred is not None :
47964786 preferred = None
47974787 fallback = lvalue_type
47984788 else :
0 commit comments