ruff
6077dc3d - [ty] Avoid falling back to `Unknown` when collecting type context constraints (#28297)

Commit
52 days ago
[ty] Avoid falling back to `Unknown` when collecting type context constraints (#28297) During fixpoint iteration, we use argument types inferred from previous iterations as type context for subsequent iterations. Arguments being forwarded to a `ParamSpec` are initially inferred without type context, as the type of the callable has not yet been inferred, and so we clear their types after the initial iteration. However, we currently fallback to `Unknown` as type context for arguments that have not yet been inferred, even if they have been intentionally cleared, which can pollute the types inferred in the next iteration. We should instead avoid providing any type context in this case. ```py from typing import TypedDict, Callable class Payload(TypedDict): x: int def forward[**P](function: Callable[P, None], /, *args: P.args, **kwargs: P.kwargs) -> None: function(*args, **kwargs) def pair[T](first: T, second: T) -> None: ... def _(payload: Payload): forward(pair, reveal_type({"x": 1}), payload) # main: dict[str, int], fixed: Payload ```
Author
Parents
Loading