Skip to content

Commit fcde1e0

Browse files
committed
GH-16791: Make Sequence.__getitem__(slice) return Self
1 parent a817b8d commit fcde1e0

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎stdlib/typing.pyi‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,15 @@ class Sequence(Reversible[_T_co], Collection[_T_co]):
684684
@overload
685685
@abstractmethod
686686
def __getitem__(self, index: int, /) -> _T_co: ...
687-
@overload
688-
@abstractmethod
689-
def __getitem__(self, index: slice[int | None], /) -> Sequence[_T_co]: ...
687+
688+
if sys.version_info >= (3, 11):
689+
@overload
690+
@abstractmethod
691+
def __getitem__(self, index: slice[int | None], /) -> Self: ...
692+
else:
693+
@overload
694+
@abstractmethod
695+
def __getitem__(self, index: slice[int | None], /) -> Sequence[_T_co]: ...
690696

691697
# Mixin methods
692698
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...

0 commit comments

Comments
 (0)