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
mypy 0.750 behaves strangely when run on the following code snippet:
from typing import FrozenSet
s1: FrozenSet[bool]
s2: FrozenSet[bool]
s3: FrozenSet[int]
reveal_type(s1) # note: Revealed type is 'builtins.frozenset[builtins.bool]'
reveal_type(s2) # note: Revealed type is 'builtins.frozenset[builtins.bool]'
reveal_type(s3) # note: Revealed type is 'builtins.frozenset[builtins.int]'
s2 = s1 # OK
s3 = s1 # error: Incompatible types in assignment (expression has type "FrozenSet[bool]", variable has type "FrozenSet[int]")
As you can see, FrozenSet doesn't seem to behave covariantly, despite the fact that typing.py says otherwise:
FrozenSet = _alias(frozenset, T_co, inst=False)
The only real difference that I see between FrozenSet and the other type aliases defined in typing.py is that it specifies a built-in type as its origin (i.e. 'frozenset') instead of an ABC.
Is this the expected behavior of mypy or a bug?
The text was updated successfully, but these errors were encountered:
But frozenset used to be invariant. I noticed it was already fixed few weeks ago in #3808, there however was no mypy release that has the fix (it just missed 0.770 by few days).
mypy 0.750 behaves strangely when run on the following code snippet:
As you can see, FrozenSet doesn't seem to behave covariantly, despite the fact that typing.py says otherwise:
The only real difference that I see between FrozenSet and the other type aliases defined in typing.py is that it specifies a built-in type as its origin (i.e. 'frozenset') instead of an ABC.
Is this the expected behavior of mypy or a bug?
The text was updated successfully, but these errors were encountered: