-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
bug when inferring TypedDicts in method parameters #6522
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
might be similar to #6462, not sure |
I think mypy is correct here, your function can be like this: def gama(delta: GamaDict) -> None:
del delta['kappa'] which is OK, because that key is optional in @JukkaL What do you think? Should we just close this? |
That does makes sense. Btw, this was very difficult to debug, I didn’t realize the error was caused because some keys were optional in one dict and requiered in the other until i did way too many tests, don’t know how hard it to catch this scenario tho, other cases are well explained, like, when you are missing keys. |
It is unfortunately hard to give a more detailed error messages in all cases. We make some efforts for protocols and for typed dicts (since they are both structural), but we don't cover all scenarios. If you have some ideas for better error messages, you can open a separate issue. |
not sure if this is a bug or i could do something to fix the error mypy raises.
bug
What is the actual behavior/output?
i get this error:
error: Argument 1 to "gama" has incompatible type "EpsilonMutationDict"; expected "GamaDict"
What is the behavior/output you expect?
I expect that mypy infers that the dict has the same
kappa
key in the dict, even tho it is an optional inGamaDict
and inEpsilonMutationDict
is notWhat are the versions of mypy and Python you are using?
python: 3.6.7
mypy: 0.670
Do you see the same issue after installing mypy from Git master?
have not tried that
What are the mypy flags you are using? (For example --strict-optional)
The text was updated successfully, but these errors were encountered: