@@ -126,15 +126,6 @@ def infer_constraints_for_callable(
126126 param_spec_arg_names = []
127127 param_spec_arg_kinds = []
128128
129- incomplete_star_mapping = False
130- for i , actuals in enumerate (formal_to_actual ):
131- for actual in actuals :
132- if actual is None and callee .arg_kinds [i ] in (ARG_STAR , ARG_STAR2 ):
133- # We can't use arguments to infer ParamSpec constraint, if only some
134- # are present in the current inference pass.
135- incomplete_star_mapping = True
136- break
137-
138129 for i , actuals in enumerate (formal_to_actual ):
139130 if isinstance (callee .arg_types [i ], UnpackType ):
140131 unpack_type = callee .arg_types [i ]
@@ -230,17 +221,16 @@ def infer_constraints_for_callable(
230221 # constraints, instead store them and infer single constraint at the end.
231222 # It is impossible to map actual kind to formal kind, so use some heuristic.
232223 # This inference is used as a fallback, so relying on heuristic should be OK.
233- if not incomplete_star_mapping :
234- param_spec_arg_types .append (
235- mapper .expand_actual_type (
236- actual_arg_type , arg_kinds [actual ], None , arg_kinds [actual ]
237- )
224+ param_spec_arg_types .append (
225+ mapper .expand_actual_type (
226+ actual_arg_type , arg_kinds [actual ], None , arg_kinds [actual ]
238227 )
239- actual_kind = arg_kinds [actual ]
240- param_spec_arg_kinds .append (
241- ARG_POS if actual_kind not in (ARG_STAR , ARG_STAR2 ) else actual_kind
242- )
243- param_spec_arg_names .append (arg_names [actual ] if arg_names else None )
228+ )
229+ actual_kind = arg_kinds [actual ]
230+ param_spec_arg_kinds .append (
231+ ARG_POS if actual_kind not in (ARG_STAR , ARG_STAR2 ) else actual_kind
232+ )
233+ param_spec_arg_names .append (arg_names [actual ] if arg_names else None )
244234 else :
245235 actual_type = mapper .expand_actual_type (
246236 actual_arg_type ,
@@ -253,7 +243,6 @@ def infer_constraints_for_callable(
253243 if (
254244 param_spec
255245 and not any (c .type_var == param_spec .id for c in constraints )
256- and not incomplete_star_mapping
257246 ):
258247 # Use ParamSpec constraint from arguments only if there are no other constraints,
259248 # since as explained above it is quite ad-hoc.
@@ -545,11 +534,7 @@ def any_constraints(options: list[list[Constraint] | None], eager: bool) -> list
545534 for option in valid_options :
546535 if option in trivial_options :
547536 continue
548- if option is not None :
549- merged_option : list [Constraint ] | None = [merge_with_any (c ) for c in option ]
550- else :
551- merged_option = None
552- merged_options .append (merged_option )
537+ merged_options .append ([merge_with_any (c ) for c in option ])
553538 return any_constraints (list (merged_options ), eager )
554539
555540 # If normal logic didn't work, try excluding trivially unsatisfiable constraint (due to
0 commit comments