ruff/crates/ty_python_semantic/resources/mdtest/diagnostics
Dhruv Manilawala 22177e6915
[ty] Surface matched overload diagnostic directly (#18452)
## Summary

This PR resolves the way diagnostics are reported for an invalid call to
an overloaded function.

If any of the steps in the overload call evaluation algorithm yields a
matching overload but it's type checking that failed, the
`no-matching-overload` diagnostic is incorrect because there is a
matching overload, it's the arguments passed that are invalid as per the
signature. So, this PR improves that by surfacing the diagnostics on the
matching overload directly.

It also provides additional context, specifically the matching overload
where this error occurred and other non-matching overloads. Consider the
following example:

```py
from typing import overload


@overload
def f() -> None: ...
@overload
def f(x: int) -> int: ...
@overload
def f(x: int, y: int) -> int: ...
def f(x: int | None = None, y: int | None = None) -> int | None:
    return None


f("a")
```

We get:

<img width="857" alt="Screenshot 2025-06-18 at 11 07 10"
src="https://github.com/user-attachments/assets/8dbcaf13-2a74-4661-aa94-1225c9402ea6"
/>


## Test Plan

Update test cases, resolve existing todos and validate the updated
snapshots.
2025-06-20 08:36:49 +05:30
..
attribute_assignment.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
invalid_argument_type.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
no_matching_overload.md [ty] Improve invalid method calls for unmatched overloads (#18122) 2025-05-15 11:39:14 -04:00
semantic_syntax_errors.md [ty] Don't warn `yield` not in function when `yield` is in function (#18008) 2025-05-21 18:16:25 +02:00
shadowing.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
single_matching_overload.md [ty] Surface matched overload diagnostic directly (#18452) 2025-06-20 08:36:49 +05:30
union_call.md [ty] Surface matched overload diagnostic directly (#18452) 2025-06-20 08:36:49 +05:30
unpacking.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unresolved_import.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unresolved_reference.md [ty] Add a note to the diagnostic if a new builtin is used on an old Python version (#18068) 2025-05-13 10:08:04 -04:00
unsupported_bool_conversion.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
version_related_syntax_errors.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00