ruff
a36fda40 - [ty] Resolve TypeVars in `call_signature_details` parameter types (#23149)

Commit
23 hours ago
[ty] Resolve TypeVars in `call_signature_details` parameter types (#23149) 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_arguments` to `from_arguments_typed` so argument types are available for TypeVar inference - Call `check_types_impl` and use `binding.specialization()` to apply the inferred specialization to annotated types An alternative would be to add a separate `call_signature_details_with_resolved_types` function to avoid changing the existing behavior, but since resolved types are strictly more useful for consumers (signature help, completions, IDE tooling), updating the existing function seems preferable.
Author
Parents
Loading