[ty] Resolve TypeVars in call_signature_details parameter types by knutwannheden · Pull Request #23149 · astral-sh/ruff (original) (raw)
Previously, call_signature_details populated parameter_types from raw param.annotated_type(), which left function-level TypeVars unresolved. For example, calling a generic function pair[T](a: T, b: T) with a str argument would report both parameters as type T instead of str.
This change adds a check_types pass after match_parameters to infer TypeVar specializations from the actual argument types at the call site. The inferred specialization is then applied to each parameter's annotated type via apply_specialization, which resolves TypeVars while preserving non-TypeVar annotations unchanged.
Two changes are needed:
- Switch from
from_argumentstofrom_arguments_typedso argument types are available for TypeVar inference - Call
check_types_impland usebinding.specialization()to apply the inferred specialization to annotated types