-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate better error message for incompatible **kwargs #8874
Generate better error message for incompatible **kwargs #8874
Comments
I would like to work on this. Seems straight forward, just need to change code here, right? |
I believe there should be multiple error messages, to inform of all callable argument type mismatch. |
Can I work on it?? |
Sure, I have not been able to continue work on it, feel free to do so. Take a look at the PR I made, let me know if you need help! |
@rohitkg98 I was looking at your PR and I saw that it passed all the checks then why it was not merged? |
is this issue still open? |
One idea for a note:
|
Hi, I plan to work on this issue. As a new and inexperienced contributor I'm open to any suggestions or comments. |
Hello, def f(a: int = 42, b: str = "hello world"): ...
d = dict(a=3, b="Bye") # is inferred as Dict[str, object]
f(**d) This code cannot be statically typed, and so we should indicate to the user a way of making it work. Solution 1from typing import TypedDict
class Params(TypedDict):
a: int
b: str
d: Params = dict(a=3, b="hello")
f(**d) Solution 2d: Dict[str, Any] = dict(a=3, b="hello")
f(**d) |
I think both have their place, the note Jukka suggests here #8874 (comment) seems like a good phrasing |
This output is from #8772:
The error messages are pretty confusing. We should special case this and produce a customized error message that explains the situation better.
Here's the code that triggers the errors:
Some ideas about what to do:
Dict[str, Any]
or a TypedDict type for the**kwargs
argument.The text was updated successfully, but these errors were encountered: