From c5a38877314a1ab22ce0585226a0e3ad9922c1a3 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sat, 19 Feb 2022 18:55:34 -0800 Subject: [PATCH 1/4] collections: add __missing__ to Counter --- stdlib/collections/__init__.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 6ea011763884..8cf2cd66978e 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -277,6 +277,7 @@ class Counter(dict[_T, int], Generic[_T]): def update(self, __m: Iterable[_T] | Iterable[tuple[_T, int]], **kwargs: int) -> None: ... @overload def update(self, __m: None = ..., **kwargs: int) -> None: ... + def __missing__(self, key: _T) -> int: ... def __delitem__(self, elem: object) -> None: ... def __eq__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... From 59ce3f96ba0538e4a9667116a33244fa15fb601a Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sat, 19 Feb 2022 23:05:44 -0800 Subject: [PATCH 2/4] positional only --- stdlib/collections/__init__.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 8cf2cd66978e..2977f2f75dd7 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -279,8 +279,12 @@ class Counter(dict[_T, int], Generic[_T]): def update(self, __m: None = ..., **kwargs: int) -> None: ... def __missing__(self, key: _T) -> int: ... def __delitem__(self, elem: object) -> None: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... + if sys.version_info >= (3, 10): + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + else: + def __eq__(self, __other: object) -> bool: ... + def __ne__(self, __other: object) -> bool: ... def __add__(self, other: Counter[_T]) -> Counter[_T]: ... def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... def __and__(self, other: Counter[_T]) -> Counter[_T]: ... From ae57cee646a6c6e707cde24ccc23498ab602fad1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 20 Feb 2022 07:07:00 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/collections/__init__.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 2977f2f75dd7..724b88d477e4 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -285,6 +285,7 @@ class Counter(dict[_T, int], Generic[_T]): else: def __eq__(self, __other: object) -> bool: ... def __ne__(self, __other: object) -> bool: ... + def __add__(self, other: Counter[_T]) -> Counter[_T]: ... def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... def __and__(self, other: Counter[_T]) -> Counter[_T]: ... From eb9ac574b027c04351c679e476f30f53f9c02230 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sun, 20 Feb 2022 01:59:52 -0800 Subject: [PATCH 4/4] Update stdlib/collections/__init__.pyi --- stdlib/collections/__init__.pyi | 3 --- 1 file changed, 3 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 724b88d477e4..c5fe236db63b 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -282,9 +282,6 @@ class Counter(dict[_T, int], Generic[_T]): if sys.version_info >= (3, 10): def __eq__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... - else: - def __eq__(self, __other: object) -> bool: ... - def __ne__(self, __other: object) -> bool: ... def __add__(self, other: Counter[_T]) -> Counter[_T]: ... def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...