mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-23 04:11:28 +08:00
Add OrderedDict.fromkeys (#6485)
This commit is contained in:
@@ -77,8 +77,10 @@ class UserList(MutableSequence[_T]):
|
||||
def clear(self) -> None: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def count(self, item: _T) -> int: ...
|
||||
# All arguments are passed to `list.index` at runtime, so the signature should be kept in line with `list.index`.
|
||||
def index(self, item: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
|
||||
def reverse(self) -> None: ...
|
||||
# All arguments are passed to `list.sort` at runtime, so the signature should be kept in line with `list.sort`.
|
||||
@overload
|
||||
def sort(self: UserList[SupportsLessThanT], *, key: None = ..., reverse: bool = ...) -> None: ...
|
||||
@overload
|
||||
@@ -273,6 +275,15 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
def keys(self) -> _OrderedDictKeysView[_KT, _VT]: ...
|
||||
def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...
|
||||
def values(self) -> _OrderedDictValuesView[_KT, _VT]: ...
|
||||
# `fromkeys` is actually inherited from `dict` at runtime, so the signature should be kept in line with `dict.fromkeys`.
|
||||
# Ideally we would not redefine it here, but the true signature of `dict.fromkeys` is not expressable in the current type system.
|
||||
# See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963.
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, __iterable: Iterable[_T], __value: None = ...) -> OrderedDict[_T, Any | None]: ...
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> OrderedDict[_T, _S]: ...
|
||||
|
||||
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
default_factory: Callable[[], _VT] | None
|
||||
@@ -314,6 +325,7 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
@overload
|
||||
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
|
||||
def copy(self: Self) -> Self: ...
|
||||
# All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, so the signature should be kept in line with `dict.fromkeys`.
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, iterable: Iterable[_T], __value: None = ...) -> ChainMap[_T, Any | None]: ...
|
||||
|
||||
Reference in New Issue
Block a user