mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-19 02:55:20 +00:00
![]()
Some checks are pending
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo clippy (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
## 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. |
||
---|---|---|
.. | ||
attribute_assignment.md | ||
invalid_argument_type.md | ||
no_matching_overload.md | ||
semantic_syntax_errors.md | ||
shadowing.md | ||
single_matching_overload.md | ||
union_call.md | ||
unpacking.md | ||
unresolved_import.md | ||
unresolved_reference.md | ||
unsupported_bool_conversion.md | ||
version_related_syntax_errors.md |