From 0804505c10388aafd812600eb1753af0f0d0d24f Mon Sep 17 00:00:00 2001 From: Mahmoud Harmouch Date: Sat, 8 May 2021 23:40:33 +0300 Subject: [PATCH] Add functools._make_key (#5370) * Add functools._make_key * Added _HashedSeq class --- stdlib/functools.pyi | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index ceb6ffcb3..fe1902800 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import SupportsLessThan +from _typeshed import SupportsItems, SupportsLessThan from typing import ( Any, Callable, @@ -7,10 +7,13 @@ from typing import ( Generic, Hashable, Iterable, + List, Mapping, NamedTuple, Optional, Sequence, + Set, + Sized, Tuple, Type, TypeVar, @@ -131,3 +134,20 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 9): def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... + +class _HashedSeq(Generic[_T], List[_T]): + __slots__: str + hashvalue: int + def __init__(self, tup: Tuple[Any, ...], hash: Callable[[object], int] = ...) -> None: ... + def __hash__(self) -> int: ... # type: ignore + +def _make_key( + args: Tuple[Hashable, ...], + kwds: SupportsItems[Any, Any], + typed: bool, + kwd_mark: Tuple[object, ...] = ..., + fasttypes: Set[type] = ..., + tuple: type = ..., + type: Any = ..., + len: Callable[[Sized], int] = ..., +) -> Union[Hashable, _HashedSeq[Any]]: ...