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
bug when inferring TypedDicts in method parameters #6522
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 in GamaDict and in EpsilonMutationDict is not
What 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)
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.
Activity
CesarLanderos commentedon Mar 7, 2019
might be similar to #6462, not sure
ilevkivskyi commentedon Mar 7, 2019
I think mypy is correct here, your function can be like this:
which is OK, because that key is optional in
GamaDict, but if you passEpsilonMutationDictit can kill a required key, so mypy prohibits this.@JukkaL What do you think? Should we just close this?
CesarLanderos commentedon Mar 7, 2019
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.
ilevkivskyi commentedon Mar 12, 2019
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.