You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error handling wrappers with **kwargs syntax #15321
main.py:6: error: Argument 1 to "my_function" has incompatible type "**Dict[str, str]"; expected "bool" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Expected Behavior
I would expect no errors. Though I can see that inputting flag="hello" could cause issues, although the error message does not help in identifying this. Also, in that case, I would expect rewriting the wrapper like below would satisfy mypy (it doesn't):
Mypy is correct here. The signature of the my_function function indicates that it requires one argument of type bool, but you are not providing any such argument when calling it. If you modify your code to supply this bool value, mypy no longer emits an error.
I made a small error in reproducing a minimal working example. If you give flag a default value, the same error occurs (I updated the original issue). If you make it a keyword-only argument, the same error occurs.
Activity
erictraut commentedon May 29, 2023
Mypy is correct here. The signature of the
my_functionfunction indicates that it requires one argument of typebool, but you are not providing any such argument when calling it. If you modify your code to supply thisboolvalue, mypy no longer emits an error.or
AlexWaygood commentedon May 29, 2023
Eric is correct
stinodego commentedon May 29, 2023
I made a small error in reproducing a minimal working example. If you give
flaga default value, the same error occurs (I updated the original issue). If you make it a keyword-only argument, the same error occurs.erictraut commentedon May 29, 2023
Yes, the updated sample demonstrates a real bug in mypy. This type checks fine in pyright.
Looks like you can work around the bug by adding a positional-only separator.
stinodego commentedon May 29, 2023
Thanks for verifying! Unfortunately, having the flag positional-only is not an option for our use case.
stinodego commentedon May 31, 2023
@AlexWaygood could this be re-opened?
AlexWaygood commentedon May 31, 2023
Not sure I agree that this is definitely a mypy bug, but I don't have time to verify/explain right now, so will reopen for now