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
This is actually correct, because Dict[str, int] is not a subtype of Dict[str, Union[str, int]] (even though int is a subtype of Union[int, str]). The reason is that Dict is defined as invariant in its type parameters, and that is done because Dict is mutable.
If we allowed that call to f(a), a would end up with a string value! To prevent this we don't consider Dict[str, Union[int, str]] a subtype of Dict[str, int].
Mypy does not detect the subtype relation (correct term?) when it comes to
dict
values:Mypy 0.4.5
The text was updated successfully, but these errors were encountered: