frozendict.pyi 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2020 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Stub for frozendict.
  16. from typing import (
  17. Any,
  18. Hashable,
  19. Iterable,
  20. Iterator,
  21. Mapping,
  22. overload,
  23. Tuple,
  24. TypeVar,
  25. )
  26. _KT = TypeVar("_KT", bound=Hashable) # Key type.
  27. _VT = TypeVar("_VT") # Value type.
  28. class frozendict(Mapping[_KT, _VT]):
  29. @overload
  30. def __init__(self, **kwargs: _VT) -> None: ...
  31. @overload
  32. def __init__(self, __map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
  33. @overload
  34. def __init__(
  35. self, __iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT
  36. ) -> None: ...
  37. def __getitem__(self, key: _KT) -> _VT: ...
  38. def __contains__(self, key: Any) -> bool: ...
  39. def copy(self, **add_or_replace: Any) -> frozendict: ...
  40. def __iter__(self) -> Iterator[_KT]: ...
  41. def __len__(self) -> int: ...
  42. def __repr__(self) -> str: ...
  43. def __hash__(self) -> int: ...