mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 08:04:24 +08:00
Use SupportsKeysAndGetItem in most Mapping constructors (#6626)
This commit is contained in:
@@ -234,7 +234,7 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
@overload
|
||||
def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __mapping: Mapping[_T, int]) -> None: ...
|
||||
def __init__(self, __mapping: SupportsKeysAndGetItem[_T, int]) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __iterable: Iterable[_T]) -> None: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
@@ -254,7 +254,7 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
# Dict.update. Not sure if we should use '# type: ignore' instead
|
||||
# and omit the type from the union.
|
||||
@overload
|
||||
def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ...
|
||||
def update(self, __m: SupportsKeysAndGetItem[_T, int], **kwargs: int) -> None: ...
|
||||
@overload
|
||||
def update(self, __m: Iterable[_T] | Iterable[tuple[_T, int]], **kwargs: int) -> None: ...
|
||||
@overload
|
||||
@@ -311,9 +311,11 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, __map: Mapping[_KT, _VT]) -> None: ...
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, __map: SupportsKeysAndGetItem[_KT, _VT]) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, __map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
|
||||
def __init__(
|
||||
self, __default_factory: Callable[[], _VT] | None, __map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(self, __default_factory: Callable[[], _VT] | None, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ...
|
||||
@overload
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
from _typeshed import SupportsKeysAndGetItem
|
||||
from importlib.abc import _LoaderProtocol
|
||||
from importlib.machinery import ModuleSpec
|
||||
from typing import (
|
||||
@@ -173,7 +174,7 @@ class CodeType:
|
||||
@final
|
||||
class MappingProxyType(Mapping[_KT, _VT_co], Generic[_KT, _VT_co]):
|
||||
__hash__: None # type: ignore[assignment]
|
||||
def __init__(self, mapping: Mapping[_KT, _VT_co]) -> None: ...
|
||||
def __init__(self, mapping: SupportsKeysAndGetItem[_KT, _VT_co]) -> None: ...
|
||||
def __getitem__(self, k: _KT) -> _VT_co: ...
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
Reference in New Issue
Block a user