collections.Counter: fix default values, allow passing None (#3699)

This commit is contained in:
Shantanu
2020-02-01 09:25:03 -08:00
committed by GitHub
parent f96fe6abc0
commit 1ca071a732

View File

@@ -241,20 +241,22 @@ class deque(MutableSequence[_T], Generic[_T]):
class Counter(Dict[_T, int], Generic[_T]):
@overload
def __init__(self, **kwargs: int) -> None: ...
def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ...
@overload
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
def __init__(self, __mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def __init__(self, __iterable: Iterable[_T]) -> None: ...
def copy(self: _S) -> _S: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
@overload
def subtract(self, __iterable: None = ...) -> None: ...
@overload
def subtract(self, __mapping: Mapping[_T, int]) -> None: ...
@overload
def subtract(self, iterable: Iterable[_T]) -> None: ...
def subtract(self, __iterable: Iterable[_T]) -> None: ...
# The Iterable[Tuple[...]] argument type is not actually desirable
# (the tuples will be added as keys, breaking type safety) but
@@ -266,7 +268,7 @@ class Counter(Dict[_T, int], Generic[_T]):
@overload
def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...
@overload
def update(self, **kwargs: int) -> None: ...
def update(self, __m: None = ..., **kwargs: int) -> None: ...
def __add__(self, other: Counter[_T]) -> Counter[_T]: ...
def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...