Add OrderedDict.fromkeys (#6485)

This commit is contained in:
Alex Waygood
2021-12-03 20:06:51 +00:00
committed by GitHub
parent 20df1808bf
commit a293f1e73f
2 changed files with 17 additions and 0 deletions

View File

@@ -777,11 +777,13 @@ class list(MutableSequence[_T], Generic[_T]):
def append(self, __object: _T) -> None: ...
def extend(self, __iterable: Iterable[_T]) -> None: ...
def pop(self, __index: SupportsIndex = ...) -> _T: ...
# Signature of `list.index` should be kept in line with `collections.UserList.index()`
def index(self, __value: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
def count(self, __value: _T) -> int: ...
def insert(self, __index: SupportsIndex, __object: _T) -> None: ...
def remove(self, __value: _T) -> None: ...
def reverse(self) -> None: ...
# Signature of `list.sort` should be kept inline with `collections.UserList.sort()`
@overload
def sort(self: list[SupportsLessThanT], *, key: None = ..., reverse: bool = ...) -> None: ...
@overload
@@ -840,6 +842,9 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def keys(self) -> dict_keys[_KT, _VT]: ...
def values(self) -> dict_values[_KT, _VT]: ...
def items(self) -> dict_items[_KT, _VT]: ...
# Signature of `dict.fromkeys` should be kept identical to `fromkeys` methods in `collections.OrderedDict`/`collections.ChainMap`
# TODO: 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 = ...) -> dict[_T, Any | None]: ...