Skip to content

Commit 18d45d6

Browse files
Broaden collections.Counter __iadd__, __isubtract__, __iand__, and __ior__ to accept any mapping (#10397)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 3d352e8 commit 18d45d6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

stdlib/collections/__init__.pyi

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from _collections_abc import dict_items, dict_keys, dict_values
3-
from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
3+
from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
44
from typing import Any, Generic, NoReturn, TypeVar, overload
55
from typing_extensions import Self, SupportsIndex, final
66

@@ -299,10 +299,10 @@ class Counter(dict[_T, int], Generic[_T]):
299299
def __pos__(self) -> Counter[_T]: ...
300300
def __neg__(self) -> Counter[_T]: ...
301301
# several type: ignores because __iadd__ is supposedly incompatible with __add__, etc.
302-
def __iadd__(self, other: Counter[_T]) -> Self: ... # type: ignore[misc]
303-
def __isub__(self, other: Counter[_T]) -> Self: ...
304-
def __iand__(self, other: Counter[_T]) -> Self: ...
305-
def __ior__(self, other: Counter[_T]) -> Self: ... # type: ignore[override,misc]
302+
def __iadd__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[misc]
303+
def __isub__(self, other: SupportsItems[_T, int]) -> Self: ...
304+
def __iand__(self, other: SupportsItems[_T, int]) -> Self: ...
305+
def __ior__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[override,misc]
306306
if sys.version_info >= (3, 10):
307307
def total(self) -> int: ...
308308
def __le__(self, other: Counter[Any]) -> bool: ...

0 commit comments

Comments
 (0)