mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-24 21:01:52 +08:00
Counter/defaultdict: Key type 'str' if initialized with keywords (#7048)
This commit is contained in:
@@ -225,7 +225,9 @@ class deque(MutableSequence[_T], Generic[_T]):
|
||||
|
||||
class Counter(dict[_T, int], Generic[_T]):
|
||||
@overload
|
||||
def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ...
|
||||
def __init__(self: Counter[_T], __iterable: None = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self: Counter[str], __iterable: None = ..., **kwargs: int) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __mapping: SupportsKeysAndGetItem[_T, int]) -> None: ...
|
||||
@overload
|
||||
@@ -298,22 +300,30 @@ class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
default_factory: Callable[[], _VT] | None
|
||||
@overload
|
||||
def __init__(self, **kwargs: _VT) -> None: ...
|
||||
def __init__(self: defaultdict[_KT, _VT]) -> None: ...
|
||||
@overload
|
||||
def __init__(self: defaultdict[str, _VT], **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ...
|
||||
def __init__(self: defaultdict[str, _VT], __default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, __map: SupportsKeysAndGetItem[_KT, _VT]) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self, __default_factory: Callable[[], _VT] | None, __map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT
|
||||
self: defaultdict[str, _VT],
|
||||
__default_factory: Callable[[], _VT] | None,
|
||||
__map: SupportsKeysAndGetItem[str, _VT],
|
||||
**kwargs: _VT,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self, __default_factory: Callable[[], _VT] | None, __iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT
|
||||
self: defaultdict[str, _VT],
|
||||
__default_factory: Callable[[], _VT] | None,
|
||||
__iterable: Iterable[tuple[str, _VT]],
|
||||
**kwargs: _VT,
|
||||
) -> None: ...
|
||||
def __missing__(self, __key: _KT) -> _VT: ...
|
||||
def __copy__(self: Self) -> Self: ...
|
||||
|
||||
Reference in New Issue
Block a user