mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-19 18:31:14 +08:00
Add SupportsIndex to list indexing. (#4804)
This commit is contained in:
@@ -726,14 +726,14 @@ class list(MutableSequence[_T], Generic[_T]):
|
||||
def __str__(self) -> str: ...
|
||||
__hash__: None # type: ignore
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> _T: ...
|
||||
def __getitem__(self, i: _SupportsIndex) -> _T: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> List[_T]: ...
|
||||
@overload
|
||||
def __setitem__(self, i: int, o: _T) -> None: ...
|
||||
def __setitem__(self, i: _SupportsIndex, o: _T) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
|
||||
def __delitem__(self, i: Union[int, slice]) -> None: ...
|
||||
def __delitem__(self, i: Union[_SupportsIndex, slice]) -> None: ...
|
||||
def __add__(self, x: List[_T]) -> List[_T]: ...
|
||||
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
|
||||
def __mul__(self, n: int) -> List[_T]: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
from _typeshed import SupportsWrite
|
||||
from typing import (
|
||||
IO,
|
||||
@@ -21,6 +22,11 @@ from typing import (
|
||||
overload,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import SupportsIndex
|
||||
else:
|
||||
from typing_extensions import SupportsIndex
|
||||
|
||||
_K = TypeVar("_K")
|
||||
_V = TypeVar("_V")
|
||||
_R = TypeVar("_R")
|
||||
@@ -264,7 +270,7 @@ class Accept(ImmutableList[Tuple[str, float]]):
|
||||
provided: bool
|
||||
def __init__(self, values: Union[None, Accept, Iterable[Tuple[str, float]]] = ...) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, key: int) -> Tuple[str, float]: ...
|
||||
def __getitem__(self, key: SupportsIndex) -> Tuple[str, float]: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> List[Tuple[str, float]]: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user