__init__.pyi 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import abc
  2. from typing import (
  3. Dict,
  4. Generic,
  5. Iterable,
  6. Iterator,
  7. List,
  8. Mapping,
  9. MutableMapping,
  10. Tuple,
  11. TypeVar,
  12. Union,
  13. overload,
  14. )
  15. class istr(str): ...
  16. upstr = istr
  17. _S = Union[str, istr]
  18. _T = TypeVar("_T")
  19. _T_co = TypeVar("_T_co", covariant=True)
  20. _D = TypeVar("_D")
  21. class MultiMapping(Mapping[_S, _T_co]):
  22. @overload
  23. @abc.abstractmethod
  24. def getall(self, key: _S) -> List[_T_co]: ...
  25. @overload
  26. @abc.abstractmethod
  27. def getall(self, key: _S, default: _D) -> Union[List[_T_co], _D]: ...
  28. @overload
  29. @abc.abstractmethod
  30. def getone(self, key: _S) -> _T_co: ...
  31. @overload
  32. @abc.abstractmethod
  33. def getone(self, key: _S, default: _D) -> Union[_T_co, _D]: ...
  34. _Arg = Union[Mapping[_S, _T], Dict[_S, _T], MultiMapping[_T], Iterable[Tuple[_S, _T]]]
  35. class MutableMultiMapping(MultiMapping[_T], MutableMapping[_S, _T], Generic[_T]):
  36. @abc.abstractmethod
  37. def add(self, key: _S, value: _T) -> None: ...
  38. @abc.abstractmethod
  39. def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
  40. @overload
  41. @abc.abstractmethod
  42. def popone(self, key: _S) -> _T: ...
  43. @overload
  44. @abc.abstractmethod
  45. def popone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  46. @overload
  47. @abc.abstractmethod
  48. def popall(self, key: _S) -> List[_T]: ...
  49. @overload
  50. @abc.abstractmethod
  51. def popall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  52. class MultiDict(MutableMultiMapping[_T], Generic[_T]):
  53. def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
  54. def copy(self) -> MultiDict[_T]: ...
  55. def __getitem__(self, k: _S) -> _T: ...
  56. def __setitem__(self, k: _S, v: _T) -> None: ...
  57. def __delitem__(self, v: _S) -> None: ...
  58. def __iter__(self) -> Iterator[_S]: ...
  59. def __len__(self) -> int: ...
  60. @overload
  61. def getall(self, key: _S) -> List[_T]: ...
  62. @overload
  63. def getall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  64. @overload
  65. def getone(self, key: _S) -> _T: ...
  66. @overload
  67. def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  68. def add(self, key: _S, value: _T) -> None: ...
  69. def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
  70. @overload
  71. def popone(self, key: _S) -> _T: ...
  72. @overload
  73. def popone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  74. @overload
  75. def popall(self, key: _S) -> List[_T]: ...
  76. @overload
  77. def popall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  78. class CIMultiDict(MutableMultiMapping[_T], Generic[_T]):
  79. def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
  80. def copy(self) -> CIMultiDict[_T]: ...
  81. def __getitem__(self, k: _S) -> _T: ...
  82. def __setitem__(self, k: _S, v: _T) -> None: ...
  83. def __delitem__(self, v: _S) -> None: ...
  84. def __iter__(self) -> Iterator[_S]: ...
  85. def __len__(self) -> int: ...
  86. @overload
  87. def getall(self, key: _S) -> List[_T]: ...
  88. @overload
  89. def getall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  90. @overload
  91. def getone(self, key: _S) -> _T: ...
  92. @overload
  93. def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  94. def add(self, key: _S, value: _T) -> None: ...
  95. def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
  96. @overload
  97. def popone(self, key: _S) -> _T: ...
  98. @overload
  99. def popone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  100. @overload
  101. def popall(self, key: _S) -> List[_T]: ...
  102. @overload
  103. def popall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  104. class MultiDictProxy(MultiMapping[_T], Generic[_T]):
  105. def __init__(
  106. self, arg: Union[MultiMapping[_T], MutableMultiMapping[_T]]
  107. ) -> None: ...
  108. def copy(self) -> MultiDict[_T]: ...
  109. def __getitem__(self, k: _S) -> _T: ...
  110. def __iter__(self) -> Iterator[_S]: ...
  111. def __len__(self) -> int: ...
  112. @overload
  113. def getall(self, key: _S) -> List[_T]: ...
  114. @overload
  115. def getall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  116. @overload
  117. def getone(self, key: _S) -> _T: ...
  118. @overload
  119. def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  120. class CIMultiDictProxy(MultiMapping[_T], Generic[_T]):
  121. def __init__(
  122. self, arg: Union[MultiMapping[_T], MutableMultiMapping[_T]]
  123. ) -> None: ...
  124. def __getitem__(self, k: _S) -> _T: ...
  125. def __iter__(self) -> Iterator[_S]: ...
  126. def __len__(self) -> int: ...
  127. @overload
  128. def getall(self, key: _S) -> List[_T]: ...
  129. @overload
  130. def getall(self, key: _S, default: _D) -> Union[List[_T], _D]: ...
  131. @overload
  132. def getone(self, key: _S) -> _T: ...
  133. @overload
  134. def getone(self, key: _S, default: _D) -> Union[_T, _D]: ...
  135. def copy(self) -> CIMultiDict[_T]: ...
  136. def getversion(
  137. md: Union[MultiDict[_T], CIMultiDict[_T], MultiDictProxy[_T], CIMultiDictProxy[_T]]
  138. ) -> int: ...