From 04f7d7a2fdafba7b91265f5d0e3fc2215316e6af Mon Sep 17 00:00:00 2001 From: Lam Son Ho Date: Fri, 11 Sep 2020 15:36:57 +0700 Subject: [PATCH] add stubs for frozendict (#4522) --- third_party/3/frozendict.pyi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 third_party/3/frozendict.pyi diff --git a/third_party/3/frozendict.pyi b/third_party/3/frozendict.pyi new file mode 100644 index 000000000..704a44c13 --- /dev/null +++ b/third_party/3/frozendict.pyi @@ -0,0 +1,27 @@ +import collections +from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, Tuple, Type, TypeVar, overload + +_S = TypeVar("_S") +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") + +class frozendict(Mapping[_KT, _VT], Generic[_KT, _VT]): + + dict_cls: Type[Dict] = ... + @overload + def __init__(self, **kwargs: _VT) -> None: ... + @overload + def __init__(self, mapping: Mapping[_KT, _VT]) -> None: ... + @overload + def __init__(self, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... + def __getitem__(self, key: _KT) -> _VT: ... + def __contains__(self, key: object) -> bool: ... + def copy(self: _S, **add_or_replace: _VT) -> _S: ... + def __iter__(self) -> Iterator[_KT]: ... + def __len__(self) -> int: ... + def __repr__(self) -> str: ... + def __hash__(self) -> int: ... + +class FrozenOrderedDict(frozendict): + + dict_cls: Type[collections.OrderedDict] = ...