datastructures.pyi 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. from datetime import datetime
  2. from os import PathLike
  3. from typing import Any
  4. from typing import Callable
  5. from typing import Collection
  6. from typing import Dict
  7. from typing import FrozenSet
  8. from typing import Generic
  9. from typing import Hashable
  10. from typing import IO
  11. from typing import Iterable
  12. from typing import Iterator
  13. from typing import List
  14. from typing import Mapping
  15. from typing import NoReturn
  16. from typing import Optional
  17. from typing import overload
  18. from typing import Set
  19. from typing import Tuple
  20. from typing import Type
  21. from typing import TypeVar
  22. from typing import Union
  23. from _typeshed.wsgi import WSGIEnvironment
  24. from typing_extensions import Literal
  25. from typing_extensions import SupportsIndex
  26. K = TypeVar("K")
  27. V = TypeVar("V")
  28. T = TypeVar("T")
  29. D = TypeVar("D")
  30. _CD = TypeVar("_CD", bound="CallbackDict")
  31. def is_immutable(self: object) -> NoReturn: ...
  32. def iter_multi_items(
  33. mapping: Union[Mapping[K, Union[V, Iterable[V]]], Iterable[Tuple[K, V]]]
  34. ) -> Iterator[Tuple[K, V]]: ...
  35. class ImmutableListMixin(List[V]):
  36. _hash_cache: Optional[int]
  37. def __hash__(self) -> int: ... # type: ignore
  38. def __delitem__(self, key: Union[SupportsIndex, slice]) -> NoReturn: ...
  39. def __iadd__(self, other: t.Any) -> NoReturn: ... # type: ignore
  40. def __imul__(self, other: int) -> NoReturn: ...
  41. def __setitem__( # type: ignore
  42. self, key: Union[int, slice], value: V
  43. ) -> NoReturn: ...
  44. def append(self, value: V) -> NoReturn: ...
  45. def remove(self, value: V) -> NoReturn: ...
  46. def extend(self, values: Iterable[V]) -> NoReturn: ...
  47. def insert(self, pos: int, value: V) -> NoReturn: ...
  48. def pop(self, index: int = -1) -> NoReturn: ...
  49. def reverse(self) -> NoReturn: ...
  50. def sort(
  51. self, key: Optional[Callable[[V], Any]] = None, reverse: bool = False
  52. ) -> NoReturn: ...
  53. class ImmutableList(ImmutableListMixin[V]): ...
  54. class ImmutableDictMixin(Dict[K, V]):
  55. _hash_cache: Optional[int]
  56. @classmethod
  57. def fromkeys( # type: ignore
  58. cls, keys: Iterable[K], value: Optional[V] = None
  59. ) -> ImmutableDictMixin[K, V]: ...
  60. def _iter_hashitems(self) -> Iterable[Hashable]: ...
  61. def __hash__(self) -> int: ... # type: ignore
  62. def setdefault(self, key: K, default: Optional[V] = None) -> NoReturn: ...
  63. def update(self, *args: Any, **kwargs: V) -> NoReturn: ...
  64. def pop(self, key: K, default: Optional[V] = None) -> NoReturn: ... # type: ignore
  65. def popitem(self) -> NoReturn: ...
  66. def __setitem__(self, key: K, value: V) -> NoReturn: ...
  67. def __delitem__(self, key: K) -> NoReturn: ...
  68. def clear(self) -> NoReturn: ...
  69. class ImmutableMultiDictMixin(ImmutableDictMixin[K, V]):
  70. def _iter_hashitems(self) -> Iterable[Hashable]: ...
  71. def add(self, key: K, value: V) -> NoReturn: ...
  72. def popitemlist(self) -> NoReturn: ...
  73. def poplist(self, key: K) -> NoReturn: ...
  74. def setlist(self, key: K, new_list: Iterable[V]) -> NoReturn: ...
  75. def setlistdefault(
  76. self, key: K, default_list: Optional[Iterable[V]] = None
  77. ) -> NoReturn: ...
  78. def _calls_update(name: str) -> Callable[[UpdateDictMixin[K, V]], Any]: ...
  79. class UpdateDictMixin(Dict[K, V]):
  80. on_update: Optional[Callable[[UpdateDictMixin[K, V]], None]]
  81. def setdefault(self, key: K, default: Optional[V] = None) -> V: ...
  82. @overload
  83. def pop(self, key: K) -> V: ...
  84. @overload
  85. def pop(self, key: K, default: Union[V, T] = ...) -> Union[V, T]: ...
  86. def __setitem__(self, key: K, value: V) -> None: ...
  87. def __delitem__(self, key: K) -> None: ...
  88. def clear(self) -> None: ...
  89. def popitem(self) -> Tuple[K, V]: ...
  90. def update(
  91. self, *args: Union[Mapping[K, V], Iterable[Tuple[K, V]]], **kwargs: V
  92. ) -> None: ...
  93. class TypeConversionDict(Dict[K, V]):
  94. @overload
  95. def get(self, key: K, default: None = ..., type: None = ...) -> Optional[V]: ...
  96. @overload
  97. def get(self, key: K, default: D, type: None = ...) -> Union[D, V]: ...
  98. @overload
  99. def get(self, key: K, default: D, type: Callable[[V], T]) -> Union[D, T]: ...
  100. @overload
  101. def get(self, key: K, type: Callable[[V], T]) -> Optional[T]: ...
  102. class ImmutableTypeConversionDict(ImmutableDictMixin[K, V], TypeConversionDict[K, V]):
  103. def copy(self) -> TypeConversionDict[K, V]: ...
  104. def __copy__(self) -> ImmutableTypeConversionDict: ...
  105. class MultiDict(TypeConversionDict[K, V]):
  106. def __init__(
  107. self,
  108. mapping: Optional[
  109. Union[Mapping[K, Union[Iterable[V], V]], Iterable[Tuple[K, V]]]
  110. ] = None,
  111. ) -> None: ...
  112. def __getitem__(self, item: K) -> V: ...
  113. def __setitem__(self, key: K, value: V) -> None: ...
  114. def add(self, key: K, value: V) -> None: ...
  115. @overload
  116. def getlist(self, key: K) -> List[V]: ...
  117. @overload
  118. def getlist(self, key: K, type: Callable[[V], T] = ...) -> List[T]: ...
  119. def setlist(self, key: K, new_list: Iterable[V]) -> None: ...
  120. def setdefault(self, key: K, default: Optional[V] = None) -> V: ...
  121. def setlistdefault(
  122. self, key: K, default_list: Optional[Iterable[V]] = None
  123. ) -> List[V]: ...
  124. def items(self, multi: bool = False) -> Iterator[Tuple[K, V]]: ... # type: ignore
  125. def lists(self) -> Iterator[Tuple[K, List[V]]]: ...
  126. def values(self) -> Iterator[V]: ... # type: ignore
  127. def listvalues(self) -> Iterator[List[V]]: ...
  128. def copy(self) -> MultiDict[K, V]: ...
  129. def deepcopy(self, memo: Any = None) -> MultiDict[K, V]: ...
  130. @overload
  131. def to_dict(self) -> Dict[K, V]: ...
  132. @overload
  133. def to_dict(self, flat: Literal[False]) -> Dict[K, List[V]]: ...
  134. def update( # type: ignore
  135. self, mapping: Union[Mapping[K, Union[Iterable[V], V]], Iterable[Tuple[K, V]]]
  136. ) -> None: ...
  137. @overload
  138. def pop(self, key: K) -> V: ...
  139. @overload
  140. def pop(self, key: K, default: Union[V, T] = ...) -> Union[V, T]: ...
  141. def popitem(self) -> Tuple[K, V]: ...
  142. def poplist(self, key: K) -> List[V]: ...
  143. def popitemlist(self) -> Tuple[K, List[V]]: ...
  144. def __copy__(self) -> MultiDict[K, V]: ...
  145. def __deepcopy__(self, memo: Any) -> MultiDict[K, V]: ...
  146. class _omd_bucket(Generic[K, V]):
  147. prev: Optional[_omd_bucket]
  148. next: Optional[_omd_bucket]
  149. key: K
  150. value: V
  151. def __init__(self, omd: OrderedMultiDict, key: K, value: V) -> None: ...
  152. def unlink(self, omd: OrderedMultiDict) -> None: ...
  153. class OrderedMultiDict(MultiDict[K, V]):
  154. _first_bucket: Optional[_omd_bucket]
  155. _last_bucket: Optional[_omd_bucket]
  156. def __init__(self, mapping: Optional[Mapping[K, V]] = None) -> None: ...
  157. def __eq__(self, other: object) -> bool: ...
  158. def __getitem__(self, key: K) -> V: ...
  159. def __setitem__(self, key: K, value: V) -> None: ...
  160. def __delitem__(self, key: K) -> None: ...
  161. def keys(self) -> Iterator[K]: ... # type: ignore
  162. def __iter__(self) -> Iterator[K]: ...
  163. def values(self) -> Iterator[V]: ... # type: ignore
  164. def items(self, multi: bool = False) -> Iterator[Tuple[K, V]]: ... # type: ignore
  165. def lists(self) -> Iterator[Tuple[K, List[V]]]: ...
  166. def listvalues(self) -> Iterator[List[V]]: ...
  167. def add(self, key: K, value: V) -> None: ...
  168. @overload
  169. def getlist(self, key: K) -> List[V]: ...
  170. @overload
  171. def getlist(self, key: K, type: Callable[[V], T] = ...) -> List[T]: ...
  172. def setlist(self, key: K, new_list: Iterable[V]) -> None: ...
  173. def setlistdefault(
  174. self, key: K, default_list: Optional[Iterable[V]] = None
  175. ) -> List[V]: ...
  176. def update( # type: ignore
  177. self, mapping: Union[Mapping[K, V], Iterable[Tuple[K, V]]]
  178. ) -> None: ...
  179. def poplist(self, key: K) -> List[V]: ...
  180. @overload
  181. def pop(self, key: K) -> V: ...
  182. @overload
  183. def pop(self, key: K, default: Union[V, T] = ...) -> Union[V, T]: ...
  184. def popitem(self) -> Tuple[K, V]: ...
  185. def popitemlist(self) -> Tuple[K, List[V]]: ...
  186. def _options_header_vkw(
  187. value: str, kw: Mapping[str, Optional[Union[str, int]]]
  188. ) -> str: ...
  189. def _unicodify_header_value(value: Union[str, int]) -> str: ...
  190. HV = Union[str, int]
  191. class Headers(Dict[str, str]):
  192. _list: List[Tuple[str, str]]
  193. def __init__(
  194. self,
  195. defaults: Optional[
  196. Union[Mapping[str, Union[HV, Iterable[HV]]], Iterable[Tuple[str, HV]]]
  197. ] = None,
  198. ) -> None: ...
  199. @overload
  200. def __getitem__(self, key: str) -> str: ...
  201. @overload
  202. def __getitem__(self, key: int) -> Tuple[str, str]: ...
  203. @overload
  204. def __getitem__(self, key: slice) -> Headers: ...
  205. @overload
  206. def __getitem__(self, key: str, _get_mode: Literal[True] = ...) -> str: ...
  207. def __eq__(self, other: object) -> bool: ...
  208. @overload # type: ignore
  209. def get(self, key: str, default: str) -> str: ...
  210. @overload
  211. def get(self, key: str, default: Optional[str] = None) -> Optional[str]: ...
  212. @overload
  213. def get(
  214. self, key: str, default: Optional[T] = None, type: Callable[[str], T] = ...
  215. ) -> Optional[T]: ...
  216. @overload
  217. def getlist(self, key: str) -> List[str]: ...
  218. @overload
  219. def getlist(self, key: str, type: Callable[[str], T]) -> List[T]: ...
  220. def get_all(self, name: str) -> List[str]: ...
  221. def items( # type: ignore
  222. self, lower: bool = False
  223. ) -> Iterator[Tuple[str, str]]: ...
  224. def keys(self, lower: bool = False) -> Iterator[str]: ... # type: ignore
  225. def values(self) -> Iterator[str]: ... # type: ignore
  226. def extend(
  227. self,
  228. *args: Union[Mapping[str, Union[HV, Iterable[HV]]], Iterable[Tuple[str, HV]]],
  229. **kwargs: Union[HV, Iterable[HV]],
  230. ) -> None: ...
  231. @overload
  232. def __delitem__(self, key: Union[str, int, slice]) -> None: ...
  233. @overload
  234. def __delitem__(self, key: str, _index_operation: Literal[False]) -> None: ...
  235. def remove(self, key: str) -> None: ...
  236. @overload # type: ignore
  237. def pop(self, key: str, default: Optional[str] = None) -> str: ...
  238. @overload
  239. def pop(
  240. self, key: Optional[int] = None, default: Optional[Tuple[str, str]] = None
  241. ) -> Tuple[str, str]: ...
  242. def popitem(self) -> Tuple[str, str]: ...
  243. def __contains__(self, key: str) -> bool: ... # type: ignore
  244. def has_key(self, key: str) -> bool: ...
  245. def __iter__(self) -> Iterator[Tuple[str, str]]: ... # type: ignore
  246. def add(self, _key: str, _value: HV, **kw: HV) -> None: ...
  247. def _validate_value(self, value: str) -> None: ...
  248. def add_header(self, _key: str, _value: HV, **_kw: HV) -> None: ...
  249. def clear(self) -> None: ...
  250. def set(self, _key: str, _value: HV, **kw: HV) -> None: ...
  251. def setlist(self, key: str, values: Iterable[HV]) -> None: ...
  252. def setdefault(self, key: str, default: HV) -> str: ... # type: ignore
  253. def setlistdefault(self, key: str, default: Iterable[HV]) -> None: ...
  254. @overload
  255. def __setitem__(self, key: str, value: HV) -> None: ...
  256. @overload
  257. def __setitem__(self, key: int, value: Tuple[str, HV]) -> None: ...
  258. @overload
  259. def __setitem__(self, key: slice, value: Iterable[Tuple[str, HV]]) -> None: ...
  260. def update(
  261. self,
  262. *args: Union[Mapping[str, HV], Iterable[Tuple[str, HV]]],
  263. **kwargs: Union[HV, Iterable[HV]],
  264. ) -> None: ...
  265. def to_wsgi_list(self) -> List[Tuple[str, str]]: ...
  266. def copy(self) -> Headers: ...
  267. def __copy__(self) -> Headers: ...
  268. class ImmutableHeadersMixin(Headers):
  269. def __delitem__(self, key: Any, _index_operation: bool = True) -> NoReturn: ...
  270. def __setitem__(self, key: Any, value: Any) -> NoReturn: ...
  271. def set(self, _key: Any, _value: Any, **kw: Any) -> NoReturn: ...
  272. def setlist(self, key: Any, values: Any) -> NoReturn: ...
  273. def add(self, _key: Any, _value: Any, **kw: Any) -> NoReturn: ...
  274. def add_header(self, _key: Any, _value: Any, **_kw: Any) -> NoReturn: ...
  275. def remove(self, key: Any) -> NoReturn: ...
  276. def extend(self, *args: Any, **kwargs: Any) -> NoReturn: ...
  277. def update(self, *args: Any, **kwargs: Any) -> NoReturn: ...
  278. def insert(self, pos: Any, value: Any) -> NoReturn: ...
  279. def pop(self, key: Any = None, default: Any = ...) -> NoReturn: ...
  280. def popitem(self) -> NoReturn: ...
  281. def setdefault(self, key: Any, default: Any) -> NoReturn: ... # type: ignore
  282. def setlistdefault(self, key: Any, default: Any) -> NoReturn: ...
  283. class EnvironHeaders(ImmutableHeadersMixin, Headers):
  284. environ: WSGIEnvironment
  285. def __init__(self, environ: WSGIEnvironment) -> None: ...
  286. def __eq__(self, other: object) -> bool: ...
  287. def __getitem__( # type: ignore
  288. self, key: str, _get_mode: Literal[False] = False
  289. ) -> str: ...
  290. def __iter__(self) -> Iterator[Tuple[str, str]]: ... # type: ignore
  291. def copy(self) -> NoReturn: ...
  292. class CombinedMultiDict(ImmutableMultiDictMixin[K, V], MultiDict[K, V]): # type: ignore
  293. dicts: List[MultiDict[K, V]]
  294. def __init__(self, dicts: Optional[Iterable[MultiDict[K, V]]]) -> None: ...
  295. @classmethod
  296. def fromkeys(cls, keys: Any, value: Any = None) -> NoReturn: ...
  297. def __getitem__(self, key: K) -> V: ...
  298. @overload # type: ignore
  299. def get(self, key: K) -> Optional[V]: ...
  300. @overload
  301. def get(self, key: K, default: Union[V, T] = ...) -> Union[V, T]: ...
  302. @overload
  303. def get(
  304. self, key: K, default: Optional[T] = None, type: Callable[[V], T] = ...
  305. ) -> Optional[T]: ...
  306. @overload
  307. def getlist(self, key: K) -> List[V]: ...
  308. @overload
  309. def getlist(self, key: K, type: Callable[[V], T] = ...) -> List[T]: ...
  310. def _keys_impl(self) -> Set[K]: ...
  311. def keys(self) -> Set[K]: ... # type: ignore
  312. def __iter__(self) -> Set[K]: ... # type: ignore
  313. def items(self, multi: bool = False) -> Iterator[Tuple[K, V]]: ... # type: ignore
  314. def values(self) -> Iterator[V]: ... # type: ignore
  315. def lists(self) -> Iterator[Tuple[K, List[V]]]: ...
  316. def listvalues(self) -> Iterator[List[V]]: ...
  317. def copy(self) -> MultiDict[K, V]: ...
  318. @overload
  319. def to_dict(self) -> Dict[K, V]: ...
  320. @overload
  321. def to_dict(self, flat: Literal[False]) -> Dict[K, List[V]]: ...
  322. def __contains__(self, key: K) -> bool: ... # type: ignore
  323. def has_key(self, key: K) -> bool: ...
  324. class FileMultiDict(MultiDict[str, "FileStorage"]):
  325. def add_file(
  326. self,
  327. name: str,
  328. file: Union[FileStorage, str, IO[bytes]],
  329. filename: Optional[str] = None,
  330. content_type: Optional[str] = None,
  331. ) -> None: ...
  332. class ImmutableDict(ImmutableDictMixin[K, V], Dict[K, V]):
  333. def copy(self) -> Dict[K, V]: ...
  334. def __copy__(self) -> ImmutableDict[K, V]: ...
  335. class ImmutableMultiDict( # type: ignore
  336. ImmutableMultiDictMixin[K, V], MultiDict[K, V]
  337. ):
  338. def copy(self) -> MultiDict[K, V]: ...
  339. def __copy__(self) -> ImmutableMultiDict[K, V]: ...
  340. class ImmutableOrderedMultiDict( # type: ignore
  341. ImmutableMultiDictMixin[K, V], OrderedMultiDict[K, V]
  342. ):
  343. def _iter_hashitems(self) -> Iterator[Tuple[int, Tuple[K, V]]]: ...
  344. def copy(self) -> OrderedMultiDict[K, V]: ...
  345. def __copy__(self) -> ImmutableOrderedMultiDict[K, V]: ...
  346. class Accept(ImmutableList[Tuple[str, int]]):
  347. provided: bool
  348. def __init__(
  349. self, values: Optional[Union[Accept, Iterable[Tuple[str, float]]]] = None
  350. ) -> None: ...
  351. def _specificity(self, value: str) -> Tuple[bool, ...]: ...
  352. def _value_matches(self, value: str, item: str) -> bool: ...
  353. @overload # type: ignore
  354. def __getitem__(self, key: str) -> int: ...
  355. @overload
  356. def __getitem__(self, key: int) -> Tuple[str, int]: ...
  357. @overload
  358. def __getitem__(self, key: slice) -> Iterable[Tuple[str, int]]: ...
  359. def quality(self, key: str) -> int: ...
  360. def __contains__(self, value: str) -> bool: ... # type: ignore
  361. def index(self, key: str) -> int: ... # type: ignore
  362. def find(self, key: str) -> int: ...
  363. def values(self) -> Iterator[str]: ...
  364. def to_header(self) -> str: ...
  365. def _best_single_match(self, match: str) -> Optional[Tuple[str, int]]: ...
  366. def best_match(
  367. self, matches: Iterable[str], default: Optional[str] = None
  368. ) -> Optional[str]: ...
  369. @property
  370. def best(self) -> str: ...
  371. def _normalize_mime(value: str) -> List[str]: ...
  372. class MIMEAccept(Accept):
  373. def _specificity(self, value: str) -> Tuple[bool, ...]: ...
  374. def _value_matches(self, value: str, item: str) -> bool: ...
  375. @property
  376. def accept_html(self) -> bool: ...
  377. @property
  378. def accept_xhtml(self) -> bool: ...
  379. @property
  380. def accept_json(self) -> bool: ...
  381. def _normalize_lang(value: str) -> List[str]: ...
  382. class LanguageAccept(Accept):
  383. def _value_matches(self, value: str, item: str) -> bool: ...
  384. def best_match(
  385. self, matches: Iterable[str], default: Optional[str] = None
  386. ) -> Optional[str]: ...
  387. class CharsetAccept(Accept):
  388. def _value_matches(self, value: str, item: str) -> bool: ...
  389. _CPT = TypeVar("_CPT", str, int, bool)
  390. _OptCPT = Optional[_CPT]
  391. def cache_property(key: str, empty: _OptCPT, type: Type[_CPT]) -> property: ...
  392. class _CacheControl(UpdateDictMixin[str, _OptCPT], Dict[str, _OptCPT]):
  393. provided: bool
  394. def __init__(
  395. self,
  396. values: Union[Mapping[str, _OptCPT], Iterable[Tuple[str, _OptCPT]]] = (),
  397. on_update: Optional[Callable[[_CacheControl], None]] = None,
  398. ) -> None: ...
  399. @property
  400. def no_cache(self) -> Optional[bool]: ...
  401. @no_cache.setter
  402. def no_cache(self, value: Optional[bool]) -> None: ...
  403. @no_cache.deleter
  404. def no_cache(self) -> None: ...
  405. @property
  406. def no_store(self) -> Optional[bool]: ...
  407. @no_store.setter
  408. def no_store(self, value: Optional[bool]) -> None: ...
  409. @no_store.deleter
  410. def no_store(self) -> None: ...
  411. @property
  412. def max_age(self) -> Optional[int]: ...
  413. @max_age.setter
  414. def max_age(self, value: Optional[int]) -> None: ...
  415. @max_age.deleter
  416. def max_age(self) -> None: ...
  417. @property
  418. def no_transform(self) -> Optional[bool]: ...
  419. @no_transform.setter
  420. def no_transform(self, value: Optional[bool]) -> None: ...
  421. @no_transform.deleter
  422. def no_transform(self) -> None: ...
  423. def _get_cache_value(self, key: str, empty: Optional[T], type: Type[T]) -> T: ...
  424. def _set_cache_value(self, key: str, value: Optional[T], type: Type[T]) -> None: ...
  425. def _del_cache_value(self, key: str) -> None: ...
  426. def to_header(self) -> str: ...
  427. @staticmethod
  428. def cache_property(key: str, empty: _OptCPT, type: Type[_CPT]) -> property: ...
  429. class RequestCacheControl(ImmutableDictMixin[str, _OptCPT], _CacheControl):
  430. @property
  431. def max_stale(self) -> Optional[int]: ...
  432. @max_stale.setter
  433. def max_stale(self, value: Optional[int]) -> None: ...
  434. @max_stale.deleter
  435. def max_stale(self) -> None: ...
  436. @property
  437. def min_fresh(self) -> Optional[int]: ...
  438. @min_fresh.setter
  439. def min_fresh(self, value: Optional[int]) -> None: ...
  440. @min_fresh.deleter
  441. def min_fresh(self) -> None: ...
  442. @property
  443. def only_if_cached(self) -> Optional[bool]: ...
  444. @only_if_cached.setter
  445. def only_if_cached(self, value: Optional[bool]) -> None: ...
  446. @only_if_cached.deleter
  447. def only_if_cached(self) -> None: ...
  448. class ResponseCacheControl(_CacheControl):
  449. @property
  450. def public(self) -> Optional[bool]: ...
  451. @public.setter
  452. def public(self, value: Optional[bool]) -> None: ...
  453. @public.deleter
  454. def public(self) -> None: ...
  455. @property
  456. def private(self) -> Optional[bool]: ...
  457. @private.setter
  458. def private(self, value: Optional[bool]) -> None: ...
  459. @private.deleter
  460. def private(self) -> None: ...
  461. @property
  462. def must_revalidate(self) -> Optional[bool]: ...
  463. @must_revalidate.setter
  464. def must_revalidate(self, value: Optional[bool]) -> None: ...
  465. @must_revalidate.deleter
  466. def must_revalidate(self) -> None: ...
  467. @property
  468. def proxy_revalidate(self) -> Optional[bool]: ...
  469. @proxy_revalidate.setter
  470. def proxy_revalidate(self, value: Optional[bool]) -> None: ...
  471. @proxy_revalidate.deleter
  472. def proxy_revalidate(self) -> None: ...
  473. @property
  474. def s_maxage(self) -> Optional[int]: ...
  475. @s_maxage.setter
  476. def s_maxage(self, value: Optional[int]) -> None: ...
  477. @s_maxage.deleter
  478. def s_maxage(self) -> None: ...
  479. @property
  480. def immutable(self) -> Optional[bool]: ...
  481. @immutable.setter
  482. def immutable(self, value: Optional[bool]) -> None: ...
  483. @immutable.deleter
  484. def immutable(self) -> None: ...
  485. def csp_property(key: str) -> property: ...
  486. class ContentSecurityPolicy(UpdateDictMixin[str, str], Dict[str, str]):
  487. @property
  488. def base_uri(self) -> Optional[str]: ...
  489. @base_uri.setter
  490. def base_uri(self, value: Optional[str]) -> None: ...
  491. @base_uri.deleter
  492. def base_uri(self) -> None: ...
  493. @property
  494. def child_src(self) -> Optional[str]: ...
  495. @child_src.setter
  496. def child_src(self, value: Optional[str]) -> None: ...
  497. @child_src.deleter
  498. def child_src(self) -> None: ...
  499. @property
  500. def connect_src(self) -> Optional[str]: ...
  501. @connect_src.setter
  502. def connect_src(self, value: Optional[str]) -> None: ...
  503. @connect_src.deleter
  504. def connect_src(self) -> None: ...
  505. @property
  506. def default_src(self) -> Optional[str]: ...
  507. @default_src.setter
  508. def default_src(self, value: Optional[str]) -> None: ...
  509. @default_src.deleter
  510. def default_src(self) -> None: ...
  511. @property
  512. def font_src(self) -> Optional[str]: ...
  513. @font_src.setter
  514. def font_src(self, value: Optional[str]) -> None: ...
  515. @font_src.deleter
  516. def font_src(self) -> None: ...
  517. @property
  518. def form_action(self) -> Optional[str]: ...
  519. @form_action.setter
  520. def form_action(self, value: Optional[str]) -> None: ...
  521. @form_action.deleter
  522. def form_action(self) -> None: ...
  523. @property
  524. def frame_ancestors(self) -> Optional[str]: ...
  525. @frame_ancestors.setter
  526. def frame_ancestors(self, value: Optional[str]) -> None: ...
  527. @frame_ancestors.deleter
  528. def frame_ancestors(self) -> None: ...
  529. @property
  530. def frame_src(self) -> Optional[str]: ...
  531. @frame_src.setter
  532. def frame_src(self, value: Optional[str]) -> None: ...
  533. @frame_src.deleter
  534. def frame_src(self) -> None: ...
  535. @property
  536. def img_src(self) -> Optional[str]: ...
  537. @img_src.setter
  538. def img_src(self, value: Optional[str]) -> None: ...
  539. @img_src.deleter
  540. def img_src(self) -> None: ...
  541. @property
  542. def manifest_src(self) -> Optional[str]: ...
  543. @manifest_src.setter
  544. def manifest_src(self, value: Optional[str]) -> None: ...
  545. @manifest_src.deleter
  546. def manifest_src(self) -> None: ...
  547. @property
  548. def media_src(self) -> Optional[str]: ...
  549. @media_src.setter
  550. def media_src(self, value: Optional[str]) -> None: ...
  551. @media_src.deleter
  552. def media_src(self) -> None: ...
  553. @property
  554. def navigate_to(self) -> Optional[str]: ...
  555. @navigate_to.setter
  556. def navigate_to(self, value: Optional[str]) -> None: ...
  557. @navigate_to.deleter
  558. def navigate_to(self) -> None: ...
  559. @property
  560. def object_src(self) -> Optional[str]: ...
  561. @object_src.setter
  562. def object_src(self, value: Optional[str]) -> None: ...
  563. @object_src.deleter
  564. def object_src(self) -> None: ...
  565. @property
  566. def prefetch_src(self) -> Optional[str]: ...
  567. @prefetch_src.setter
  568. def prefetch_src(self, value: Optional[str]) -> None: ...
  569. @prefetch_src.deleter
  570. def prefetch_src(self) -> None: ...
  571. @property
  572. def plugin_types(self) -> Optional[str]: ...
  573. @plugin_types.setter
  574. def plugin_types(self, value: Optional[str]) -> None: ...
  575. @plugin_types.deleter
  576. def plugin_types(self) -> None: ...
  577. @property
  578. def report_to(self) -> Optional[str]: ...
  579. @report_to.setter
  580. def report_to(self, value: Optional[str]) -> None: ...
  581. @report_to.deleter
  582. def report_to(self) -> None: ...
  583. @property
  584. def report_uri(self) -> Optional[str]: ...
  585. @report_uri.setter
  586. def report_uri(self, value: Optional[str]) -> None: ...
  587. @report_uri.deleter
  588. def report_uri(self) -> None: ...
  589. @property
  590. def sandbox(self) -> Optional[str]: ...
  591. @sandbox.setter
  592. def sandbox(self, value: Optional[str]) -> None: ...
  593. @sandbox.deleter
  594. def sandbox(self) -> None: ...
  595. @property
  596. def script_src(self) -> Optional[str]: ...
  597. @script_src.setter
  598. def script_src(self, value: Optional[str]) -> None: ...
  599. @script_src.deleter
  600. def script_src(self) -> None: ...
  601. @property
  602. def script_src_attr(self) -> Optional[str]: ...
  603. @script_src_attr.setter
  604. def script_src_attr(self, value: Optional[str]) -> None: ...
  605. @script_src_attr.deleter
  606. def script_src_attr(self) -> None: ...
  607. @property
  608. def script_src_elem(self) -> Optional[str]: ...
  609. @script_src_elem.setter
  610. def script_src_elem(self, value: Optional[str]) -> None: ...
  611. @script_src_elem.deleter
  612. def script_src_elem(self) -> None: ...
  613. @property
  614. def style_src(self) -> Optional[str]: ...
  615. @style_src.setter
  616. def style_src(self, value: Optional[str]) -> None: ...
  617. @style_src.deleter
  618. def style_src(self) -> None: ...
  619. @property
  620. def style_src_attr(self) -> Optional[str]: ...
  621. @style_src_attr.setter
  622. def style_src_attr(self, value: Optional[str]) -> None: ...
  623. @style_src_attr.deleter
  624. def style_src_attr(self) -> None: ...
  625. @property
  626. def style_src_elem(self) -> Optional[str]: ...
  627. @style_src_elem.setter
  628. def style_src_elem(self, value: Optional[str]) -> None: ...
  629. @style_src_elem.deleter
  630. def style_src_elem(self) -> None: ...
  631. @property
  632. def worker_src(self) -> Optional[str]: ...
  633. @worker_src.setter
  634. def worker_src(self, value: Optional[str]) -> None: ...
  635. @worker_src.deleter
  636. def worker_src(self) -> None: ...
  637. provided: bool
  638. def __init__(
  639. self,
  640. values: Union[Mapping[str, str], Iterable[Tuple[str, str]]] = (),
  641. on_update: Optional[Callable[[ContentSecurityPolicy], None]] = None,
  642. ) -> None: ...
  643. def _get_value(self, key: str) -> Optional[str]: ...
  644. def _set_value(self, key: str, value: str) -> None: ...
  645. def _del_value(self, key: str) -> None: ...
  646. def to_header(self) -> str: ...
  647. class CallbackDict(UpdateDictMixin[K, V], Dict[K, V]):
  648. def __init__(
  649. self,
  650. initial: Optional[Union[Mapping[K, V], Iterable[Tuple[K, V]]]] = None,
  651. on_update: Optional[Callable[[_CD], None]] = None,
  652. ) -> None: ...
  653. class HeaderSet(Set[str]):
  654. _headers: List[str]
  655. _set: Set[str]
  656. on_update: Optional[Callable[[HeaderSet], None]]
  657. def __init__(
  658. self,
  659. headers: Optional[Iterable[str]] = None,
  660. on_update: Optional[Callable[[HeaderSet], None]] = None,
  661. ) -> None: ...
  662. def add(self, header: str) -> None: ...
  663. def remove(self, header: str) -> None: ...
  664. def update(self, iterable: Iterable[str]) -> None: ... # type: ignore
  665. def discard(self, header: str) -> None: ...
  666. def find(self, header: str) -> int: ...
  667. def index(self, header: str) -> int: ...
  668. def clear(self) -> None: ...
  669. def as_set(self, preserve_casing: bool = False) -> Set[str]: ...
  670. def to_header(self) -> str: ...
  671. def __getitem__(self, idx: int) -> str: ...
  672. def __delitem__(self, idx: int) -> None: ...
  673. def __setitem__(self, idx: int, value: str) -> None: ...
  674. def __contains__(self, header: str) -> bool: ... # type: ignore
  675. def __len__(self) -> int: ...
  676. def __iter__(self) -> Iterator[str]: ...
  677. class ETags(Collection[str]):
  678. _strong: FrozenSet[str]
  679. _weak: FrozenSet[str]
  680. star_tag: bool
  681. def __init__(
  682. self,
  683. strong_etags: Optional[Iterable[str]] = None,
  684. weak_etags: Optional[Iterable[str]] = None,
  685. star_tag: bool = False,
  686. ) -> None: ...
  687. def as_set(self, include_weak: bool = False) -> Set[str]: ...
  688. def is_weak(self, etag: str) -> bool: ...
  689. def is_strong(self, etag: str) -> bool: ...
  690. def contains_weak(self, etag: str) -> bool: ...
  691. def contains(self, etag: str) -> bool: ...
  692. def contains_raw(self, etag: str) -> bool: ...
  693. def to_header(self) -> str: ...
  694. def __call__(
  695. self,
  696. etag: Optional[str] = None,
  697. data: Optional[bytes] = None,
  698. include_weak: bool = False,
  699. ) -> bool: ...
  700. def __len__(self) -> int: ...
  701. def __iter__(self) -> Iterator[str]: ...
  702. def __contains__(self, item: str) -> bool: ... # type: ignore
  703. class IfRange:
  704. etag: Optional[str]
  705. date: Optional[datetime]
  706. def __init__(
  707. self, etag: Optional[str] = None, date: Optional[datetime] = None
  708. ) -> None: ...
  709. def to_header(self) -> str: ...
  710. class Range:
  711. units: str
  712. ranges: List[Tuple[int, Optional[int]]]
  713. def __init__(self, units: str, ranges: List[Tuple[int, Optional[int]]]) -> None: ...
  714. def range_for_length(self, length: Optional[int]) -> Optional[Tuple[int, int]]: ...
  715. def make_content_range(self, length: Optional[int]) -> Optional[ContentRange]: ...
  716. def to_header(self) -> str: ...
  717. def to_content_range_header(self, length: Optional[int]) -> Optional[str]: ...
  718. def _callback_property(name: str) -> property: ...
  719. class ContentRange:
  720. on_update: Optional[Callable[[ContentRange], None]]
  721. def __init__(
  722. self,
  723. units: Optional[str],
  724. start: Optional[int],
  725. stop: Optional[int],
  726. length: Optional[int] = None,
  727. on_update: Optional[Callable[[ContentRange], None]] = None,
  728. ) -> None: ...
  729. @property
  730. def units(self) -> Optional[str]: ...
  731. @units.setter
  732. def units(self, value: Optional[str]) -> None: ...
  733. @property
  734. def start(self) -> Optional[int]: ...
  735. @start.setter
  736. def start(self, value: Optional[int]) -> None: ...
  737. @property
  738. def stop(self) -> Optional[int]: ...
  739. @stop.setter
  740. def stop(self, value: Optional[int]) -> None: ...
  741. @property
  742. def length(self) -> Optional[int]: ...
  743. @length.setter
  744. def length(self, value: Optional[int]) -> None: ...
  745. def set(
  746. self,
  747. start: Optional[int],
  748. stop: Optional[int],
  749. length: Optional[int] = None,
  750. units: Optional[str] = "bytes",
  751. ) -> None: ...
  752. def unset(self) -> None: ...
  753. def to_header(self) -> str: ...
  754. class Authorization(ImmutableDictMixin[str, str], Dict[str, str]):
  755. type: str
  756. def __init__(
  757. self,
  758. auth_type: str,
  759. data: Optional[Union[Mapping[str, str], Iterable[Tuple[str, str]]]] = None,
  760. ) -> None: ...
  761. @property
  762. def username(self) -> Optional[str]: ...
  763. @property
  764. def password(self) -> Optional[str]: ...
  765. @property
  766. def realm(self) -> Optional[str]: ...
  767. @property
  768. def nonce(self) -> Optional[str]: ...
  769. @property
  770. def uri(self) -> Optional[str]: ...
  771. @property
  772. def nc(self) -> Optional[str]: ...
  773. @property
  774. def cnonce(self) -> Optional[str]: ...
  775. @property
  776. def response(self) -> Optional[str]: ...
  777. @property
  778. def opaque(self) -> Optional[str]: ...
  779. @property
  780. def qop(self) -> Optional[str]: ...
  781. def to_header(self) -> str: ...
  782. def auth_property(name: str, doc: Optional[str] = None) -> property: ...
  783. def _set_property(name: str, doc: Optional[str] = None) -> property: ...
  784. class WWWAuthenticate(UpdateDictMixin[str, str], Dict[str, str]):
  785. _require_quoting: FrozenSet[str]
  786. def __init__(
  787. self,
  788. auth_type: Optional[str] = None,
  789. values: Optional[Union[Mapping[str, str], Iterable[Tuple[str, str]]]] = None,
  790. on_update: Optional[Callable[[WWWAuthenticate], None]] = None,
  791. ) -> None: ...
  792. def set_basic(self, realm: str = ...) -> None: ...
  793. def set_digest(
  794. self,
  795. realm: str,
  796. nonce: str,
  797. qop: Iterable[str] = ("auth",),
  798. opaque: Optional[str] = None,
  799. algorithm: Optional[str] = None,
  800. stale: bool = False,
  801. ) -> None: ...
  802. def to_header(self) -> str: ...
  803. @property
  804. def type(self) -> Optional[str]: ...
  805. @type.setter
  806. def type(self, value: Optional[str]) -> None: ...
  807. @property
  808. def realm(self) -> Optional[str]: ...
  809. @realm.setter
  810. def realm(self, value: Optional[str]) -> None: ...
  811. @property
  812. def domain(self) -> HeaderSet: ...
  813. @property
  814. def nonce(self) -> Optional[str]: ...
  815. @nonce.setter
  816. def nonce(self, value: Optional[str]) -> None: ...
  817. @property
  818. def opaque(self) -> Optional[str]: ...
  819. @opaque.setter
  820. def opaque(self, value: Optional[str]) -> None: ...
  821. @property
  822. def algorithm(self) -> Optional[str]: ...
  823. @algorithm.setter
  824. def algorithm(self, value: Optional[str]) -> None: ...
  825. @property
  826. def qop(self) -> HeaderSet: ...
  827. @property
  828. def stale(self) -> Optional[bool]: ...
  829. @stale.setter
  830. def stale(self, value: Optional[bool]) -> None: ...
  831. @staticmethod
  832. def auth_property(name: str, doc: Optional[str] = None) -> property: ...
  833. class FileStorage:
  834. name: Optional[str]
  835. stream: IO[bytes]
  836. filename: Optional[str]
  837. headers: Headers
  838. _parsed_content_type: Tuple[str, Dict[str, str]]
  839. def __init__(
  840. self,
  841. stream: Optional[IO[bytes]] = None,
  842. filename: Optional[str] = None,
  843. name: Optional[str] = None,
  844. content_type: Optional[str] = None,
  845. content_length: Optional[int] = None,
  846. headers: Optional[Headers] = None,
  847. ) -> None: ...
  848. def _parse_content_type(self) -> None: ...
  849. @property
  850. def content_type(self) -> str: ...
  851. @property
  852. def content_length(self) -> int: ...
  853. @property
  854. def mimetype(self) -> str: ...
  855. @property
  856. def mimetype_params(self) -> Dict[str, str]: ...
  857. def save(
  858. self, dst: Union[str, PathLike, IO[bytes]], buffer_size: int = ...
  859. ) -> None: ...
  860. def close(self) -> None: ...
  861. def __bool__(self) -> bool: ...
  862. def __getattr__(self, name: str) -> Any: ...
  863. def __iter__(self) -> Iterator[bytes]: ...
  864. def __repr__(self) -> str: ...