-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Optional arguments mixed with **kwargs #11084
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
Comments
Another minimal example I just threw together when going to report this bug myself def example(name: str, arg2: bool, **kwargs):
pass
kwargs = {
'arg2': True,
'num': 1
}
example("test", **kwargs) gets
|
This is because mypy infers |
Another example, with
Output:
|
One solution for this would be having mypy infer a more specific Marking the dict literals as |
Is this a duplicate of #8862? |
Yes |
Bug Report
Mypy seems to try to compare provided arguments from
**kwargs
dict against specified arguments with default values.While the code executes and runs perfectly fine in cpython 3.8.10, mypy says it's incorrect.
I think it might be related to #9676 as the initial symptom seems to match what I am observing in my case. However, I think that examples discussed there are different from the ones I encounter (as in: "possibly of different origin").
To Reproduce
somefile.py
somefile2.py
Expected Behavior
No errors
Actual Behavior
For the second file, note that no error was reported on line 13 below. My guess is that the
somearg1
(int) was (incorrectly!) matched tobaz
(int):Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: