mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
collections.Counter: fix default values, allow passing None (#3699)
This commit is contained in:
@@ -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]: ...
|
||||
|
||||
Reference in New Issue
Block a user