mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-11-03 21:23:45 +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.
		
	
					 | 
			||
|---|---|---|
| .. | ||
| conditionals | ||
| assert.md | ||
| assignment.md | ||
| bool-call.md | ||
| boolean.md | ||
| complex_target.md | ||
| hasattr.md | ||
| isinstance.md | ||
| issubclass.md | ||
| match.md | ||
| post_if_statement.md | ||
| truthiness.md | ||
| type.md | ||
| type_guards.md | ||
| while.md | ||