Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]: ...
Comment thread
AlexWaygood marked this conversation as resolved.
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down