Open tusharsadhwani opened 1 year ago
The error isn't repeated for each overload. It's repeated for each required parameter in the selected overload. This is consistent with non-overloaded functions and normal keyword parameters.
def func(x: str, y: int, z: complex):
pass
func(1, "", "") # Three errors emitted, one for each parameter
I think mypy's doing the right thing here. Pyright's behavior is the same, FWIW.
Ah, I see. The Argument 2 of "loads"
bit confused me. I thought it's talking about the same parameter.
Re-opening as a usability issue to improve the error messages here, as I agree the "argument 2 to loads" wording is confusing. For comparison, pyright says this: Argument of type "object" cannot be assigned to parameter "cls" of type "type[JSONDecoder] | None" in function "loads"
(and the same for the other parameters).
I think we should also give the name of the argument where there is a type mismatch instead of just saying "argument 2", though obviously we don't need to match pyright's error exactly.
That is indeed much better, I'd like to work on this issue then.
Bug Report
In case of
**kwargs
being passed to an overloaded function, one issue gets raised for every overload of that function. This problem is not present when passing a regular incompatible type to that overloaded function, eg.int
To Reproduce
Gist: https://mypy-play.net/?mypy=master&python=3.11&gist=8d7f8bb50c5f9022469b59ec127df614
The bug won't reproduce for eg. if
**kwargs: object
was replaced withx: object
.Expected Behavior
Single issue being raised.
Actual Behavior