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
sandbox.py:8: error: Invariant type variable "V" used in protocol where covariant one is expected
sandbox.py:39: error: Overloaded function signatures 3 and 4 overlap with incompatible return types
sandbox.py:54: error: Overloaded function signatures 5 and 6 overlap with incompatible return types
Your Environment
Mypy version used: mypy 0.950
Mypy command-line flags:
Mypy configuration options from mypy.ini (and other config files):
Python version used: Python 3.10.4
Operating system and version: Windows 10
The text was updated successfully, but these errors were encountered:
I thiiiiink mypy is correct here, although it's certainly not intuitive.
The tricky thing is dict is invariant in its key type. So if you pass SupportsKeysAndGetItem[StrSubclass, int] and no extra kwargs, both overloads would match, but overload 1 returns you a dict[StrSubclass, int] and overload 2 returns you a dict[str, int] and those are incompatible.
mypy reports errors only in FrozendictBase methods.
SupportsKeysAndGetItem is also invariant in both key and values in this example, so SupportsKeysAndGetItem[StrSubclass, int] is not subclass of SupportsKeysAndGetItem[str, int]; thus, overload 2 is not macthed.
Bug Report
Return types are compatible.
Return types are also compatible, but mypy reports an error.
To Reproduce
sandbox.py
.mypy sandbox.py
.Expected Behavior
This is due to #5775.
Actual Behavior
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: