Use _typeshed.Self in Python 2, too (#6932)

This commit is contained in:
Alex Waygood
2022-01-16 22:44:51 +00:00
committed by GitHub
parent 0949e9e90d
commit 6a88d5e7ae
29 changed files with 156 additions and 160 deletions

View File

@@ -1,3 +1,4 @@
from _typeshed import Self
from typing import (
AbstractSet,
Any,
@@ -28,7 +29,6 @@ from typing import (
Set = AbstractSet
_S = TypeVar("_S")
_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
@@ -61,7 +61,7 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __setitem__(self, i: int, x: _T) -> None: ...
def __contains__(self, o: _T) -> bool: ...
def __reversed__(self) -> Iterator[_T]: ...
def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
def __iadd__(self: Self, iterable: Iterable[_T]) -> Self: ...
class Counter(Dict[_T, int], Generic[_T]):
@overload
@@ -70,7 +70,7 @@ class Counter(Dict[_T, int], Generic[_T]):
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def copy(self: _S) -> _S: ...
def copy(self: Self) -> Self: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: int | None = ...) -> List[Tuple[_T, int]]: ...
@overload
@@ -99,7 +99,7 @@ class Counter(Dict[_T, int], Generic[_T]):
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def copy(self: _S) -> _S: ...
def copy(self: Self) -> Self: ...
def __reversed__(self) -> Iterator[_KT]: ...
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
@@ -119,4 +119,4 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
def copy(self: _S) -> _S: ...
def copy(self: Self) -> Self: ...