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
# Mutable list is invariant
list1: list[int] = [10]
list2: list[int | None] = list1 # Error
# Immutable list (tuple) is covariant
tuple1: tuple[int, ...] = (10, )
tuple2: tuple[int | None, ...] = tuple1 # No Error
# Mutable dict is invariant
dict1: dict[str, int] = {"a": 10}
dict2: dict[str, int | None] = dict1 # Error
# Immutable dict is also invariant????
fdict1: frozendict[str, int] = frozendict(a=10)
fdict2: frozendict[str, int | None] = fdict1 # Error
# But I think this should not be an error
# I think Key and Value should booth be covariant
As far as I understand: The Generic TypeVar parameters _KT and _VT do not have the option, covariant set:
Activity