Skip to content

Commit be3089d

Browse files
experiment: make Mapping and Sequence disjoint
1 parent a75102f commit be3089d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

stdlib/typing.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ from types import (
2121
UnionType,
2222
WrapperDescriptorType,
2323
)
24-
from typing_extensions import Never as _Never, deprecated
24+
from typing_extensions import Never as _Never, deprecated, disjoint_base as _disjoint_base
2525

2626
if sys.version_info >= (3, 14):
2727
from _typeshed import EvaluateFunc
@@ -678,6 +678,7 @@ class Collection(Iterable[_T_co], Container[Any], Protocol[_T_co]):
678678
@abstractmethod
679679
def __len__(self) -> int: ...
680680

681+
@_disjoint_base
681682
class Sequence(Reversible[_T_co], Collection[_T_co]):
682683
@overload
683684
@abstractmethod
@@ -804,6 +805,7 @@ class ValuesView(MappingView, Collection[_VT_co]):
804805
# but dict and types.MappingProxyType (the vast majority of Mapping types)
805806
# don't allow keyword arguments.
806807

808+
@_disjoint_base
807809
class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
808810
# TODO: We wish the key type could also be covariant, but that doesn't work,
809811
# see discussion in https://github.com/python/typing/pull/273.

0 commit comments

Comments
 (0)