Improve stubs for sequence types (#6386)

This commit is contained in:
Alex Waygood
2021-11-27 03:09:38 +00:00
committed by GitHub
parent 6130c2459e
commit 98af7d667f
9 changed files with 32 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
import sys
from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, TypeVar, Union, overload
from typing_extensions import Literal
from typing_extensions import Literal, SupportsIndex
_IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
_FloatTypeCode = Literal["f", "d"]
@@ -48,14 +48,14 @@ class array(MutableSequence[_T], Generic[_T]):
def tostring(self) -> bytes: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, __i: int) -> _T: ...
def __getitem__(self, __i: SupportsIndex) -> _T: ...
@overload
def __getitem__(self, __s: slice) -> array[_T]: ...
@overload # type: ignore # Overrides MutableSequence
def __setitem__(self, __i: int, __o: _T) -> None: ...
def __setitem__(self, __i: SupportsIndex, __o: _T) -> None: ...
@overload
def __setitem__(self, __s: slice, __o: array[_T]) -> None: ...
def __delitem__(self, __i: int | slice) -> None: ...
def __delitem__(self, __i: SupportsIndex | slice) -> None: ...
def __add__(self, __x: array[_T]) -> array[_T]: ...
def __ge__(self, __other: array[_T]) -> bool: ...
def __gt__(self, __other: array[_T]) -> bool: ...