mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Add missing methods to collections classes (#6388)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
@@ -4,6 +4,9 @@ from _typeshed import Self
|
||||
from typing import Any, Dict, Generic, NoReturn, Tuple, Type, TypeVar, overload
|
||||
from typing_extensions import final
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Reversible, Sequence
|
||||
else:
|
||||
@@ -126,6 +129,8 @@ class UserString(Sequence[str]):
|
||||
def isspace(self) -> bool: ...
|
||||
def istitle(self) -> bool: ...
|
||||
def isupper(self) -> bool: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def isascii(self) -> bool: ...
|
||||
def join(self, seq: Iterable[str]) -> str: ...
|
||||
def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...
|
||||
def lower(self: _UserStringT) -> _UserStringT: ...
|
||||
@@ -200,6 +205,8 @@ class deque(MutableSequence[_T], Generic[_T]):
|
||||
def __add__(self: _S, __other: _S) -> _S: ...
|
||||
def __mul__(self: _S, __other: int) -> _S: ...
|
||||
def __imul__(self: _S, __other: int) -> _S: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
|
||||
|
||||
class Counter(Dict[_T, int], Generic[_T]):
|
||||
@overload
|
||||
@@ -240,6 +247,8 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
def __isub__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ... # type: ignore[override]
|
||||
if sys.version_info >= (3, 10):
|
||||
def total(self) -> int: ...
|
||||
|
||||
@final
|
||||
class _OrderedDictKeysView(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # type: ignore[misc]
|
||||
@@ -301,3 +310,10 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def pop(self, key: _KT) -> _VT: ...
|
||||
@overload
|
||||
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, iterable: Iterable[_T], __value: None = ...) -> ChainMap[_T, Any | None]: ...
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> ChainMap[_T, _S]: ...
|
||||
|
||||
@@ -51,6 +51,7 @@ codecs.CodecInfo.streamreader
|
||||
codecs.CodecInfo.streamwriter
|
||||
# Coroutine and Generator properties are added programmatically
|
||||
collections.ChainMap.get # Adding None to the underlying Mapping Union messed up mypy
|
||||
collections.ChainMap.fromkeys # Runtime has *args which can really only be one argument
|
||||
# Coroutine and Generator properties are added programmatically
|
||||
collections.abc.Coroutine.cr_await
|
||||
collections.abc.Coroutine.cr_code
|
||||
|
||||
Reference in New Issue
Block a user