Broaden collections.Counter __iadd__, __isubtract__, __iand__, and __ior__ to accept any mapping (#10397)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Andrew Sansom
2023-07-03 02:27:17 -05:00
committed by GitHub
parent 3d352e85e5
commit 18d45d62aa

View File

@@ -1,6 +1,6 @@
import sys
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from typing import Any, Generic, NoReturn, TypeVar, overload
from typing_extensions import Self, SupportsIndex, final
@@ -299,10 +299,10 @@ class Counter(dict[_T, int], Generic[_T]):
def __pos__(self) -> Counter[_T]: ...
def __neg__(self) -> Counter[_T]: ...
# several type: ignores because __iadd__ is supposedly incompatible with __add__, etc.
def __iadd__(self, other: Counter[_T]) -> Self: ... # type: ignore[misc]
def __isub__(self, other: Counter[_T]) -> Self: ...
def __iand__(self, other: Counter[_T]) -> Self: ...
def __ior__(self, other: Counter[_T]) -> Self: ... # type: ignore[override,misc]
def __iadd__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[misc]
def __isub__(self, other: SupportsItems[_T, int]) -> Self: ...
def __iand__(self, other: SupportsItems[_T, int]) -> Self: ...
def __ior__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[override,misc]
if sys.version_info >= (3, 10):
def total(self) -> int: ...
def __le__(self, other: Counter[Any]) -> bool: ...