ruff/crates/ty_python_semantic/resources/mdtest/generics/pep695
Douglas Creager 4fad15805b
[ty] Use first matching constructor overload when inferring specializations (#18204)
This is a follow-on to #18155. For the example raised in
https://github.com/astral-sh/ty/issues/370:

```py
import tempfile

with tempfile.TemporaryDirectory() as tmp: ...
```

the new logic would notice that both overloads of `TemporaryDirectory`
match, and combine their specializations, resulting in an inferred type
of `str | bytes`.

This PR updates the logic to match our other handling of other calls,
where we only keep the _first_ matching overload. The result for this
example then becomes `str`, matching the runtime behavior. (We still do
not implement the full [overload resolution
algorithm](https://typing.python.org/en/latest/spec/overload.html#overload-call-evaluation)
from the spec.)
2025-05-19 15:12:28 -04:00
..
classes.md [ty] Use first matching constructor overload when inferring specializations (#18204) 2025-05-19 15:12:28 -04:00
functions.md [ty] Fix Inconsistent casing in diagnostic (#18084) 2025-05-14 08:26:48 +02:00
variables.md [ty] Handle typevars that have other typevars as a default (#17956) 2025-05-08 19:01:27 -04:00
variance.md [ty] Check base classes when determining subtyping etc for generic aliases (#17927) 2025-05-07 15:21:11 -04:00