Type hint support for slices and __index__ in SequenceProxy

This commit is contained in:
Jakub Kuczys 2022-10-03 13:27:38 +02:00 committed by GitHub
parent c6decedf7b
commit d2c6a32543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,7 @@ from typing import (
Protocol,
Set,
Sequence,
SupportsIndex,
Tuple,
Type,
TypeVar,
@ -227,7 +228,15 @@ class SequenceProxy(Sequence[T_co]):
def __repr__(self) -> str:
return f"SequenceProxy({self.__proxied!r})"
def __getitem__(self, idx: int) -> T_co:
@overload
def __getitem__(self, idx: SupportsIndex) -> T_co:
...
@overload
def __getitem__(self, idx: slice) -> List[T_co]:
...
def __getitem__(self, idx: Union[SupportsIndex, slice]) -> Union[T_co, List[T_co]]:
return self.__copied[idx]
def __len__(self) -> int: