massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / Werkzeug / werkzeug / formparser.pyi
1 from _typeshed.wsgi import WSGIEnvironment
2 from typing import IO, Any, Callable, Generator, Iterable, Mapping, NoReturn, Optional, Protocol, Text, Tuple, TypeVar
3
4 from .datastructures import Headers
5
6 _Dict = Any
7 _ParseFunc = Callable[[IO[bytes], str, Optional[int], Mapping[str, str]], Tuple[IO[bytes], _Dict, _Dict]]
8
9 _F = TypeVar("_F", bound=Callable[..., Any])
10
11 class _StreamFactory(Protocol):
12     def __call__(
13         self, total_content_length: int | None, filename: str, content_type: str, content_length: int | None = ...
14     ) -> IO[bytes]: ...
15
16 def default_stream_factory(
17     total_content_length: int | None, filename: str, content_type: str, content_length: int | None = ...
18 ) -> IO[bytes]: ...
19 def parse_form_data(
20     environ: WSGIEnvironment,
21     stream_factory: _StreamFactory | None = ...,
22     charset: Text = ...,
23     errors: Text = ...,
24     max_form_memory_size: int | None = ...,
25     max_content_length: int | None = ...,
26     cls: Callable[[], _Dict] | None = ...,
27     silent: bool = ...,
28 ) -> tuple[IO[bytes], _Dict, _Dict]: ...
29 def exhaust_stream(f: _F) -> _F: ...
30
31 class FormDataParser(object):
32     stream_factory: _StreamFactory
33     charset: Text
34     errors: Text
35     max_form_memory_size: int | None
36     max_content_length: int | None
37     cls: Callable[[], _Dict]
38     silent: bool
39     def __init__(
40         self,
41         stream_factory: _StreamFactory | None = ...,
42         charset: Text = ...,
43         errors: Text = ...,
44         max_form_memory_size: int | None = ...,
45         max_content_length: int | None = ...,
46         cls: Callable[[], _Dict] | None = ...,
47         silent: bool = ...,
48     ) -> None: ...
49     def get_parse_func(self, mimetype: str, options: Any) -> _ParseFunc | None: ...
50     def parse_from_environ(self, environ: WSGIEnvironment) -> tuple[IO[bytes], _Dict, _Dict]: ...
51     def parse(
52         self, stream: IO[bytes], mimetype: Text, content_length: int | None, options: Mapping[str, str] | None = ...
53     ) -> tuple[IO[bytes], _Dict, _Dict]: ...
54     parse_functions: dict[Text, _ParseFunc]
55
56 def is_valid_multipart_boundary(boundary: str) -> bool: ...
57 def parse_multipart_headers(iterable: Iterable[Text | bytes]) -> Headers: ...
58
59 class MultiPartParser(object):
60     charset: Text
61     errors: Text
62     max_form_memory_size: int | None
63     stream_factory: _StreamFactory
64     cls: Callable[[], _Dict]
65     buffer_size: int
66     def __init__(
67         self,
68         stream_factory: _StreamFactory | None = ...,
69         charset: Text = ...,
70         errors: Text = ...,
71         max_form_memory_size: int | None = ...,
72         cls: Callable[[], _Dict] | None = ...,
73         buffer_size: int = ...,
74     ) -> None: ...
75     def fail(self, message: Text) -> NoReturn: ...
76     def get_part_encoding(self, headers: Mapping[str, str]) -> str | None: ...
77     def get_part_charset(self, headers: Mapping[str, str]) -> Text: ...
78     def start_file_streaming(
79         self, filename: Text | bytes, headers: Mapping[str, str], total_content_length: int | None
80     ) -> tuple[Text, IO[bytes]]: ...
81     def in_memory_threshold_reached(self, bytes: Any) -> NoReturn: ...
82     def validate_boundary(self, boundary: str | None) -> None: ...
83     def parse_lines(
84         self, file: Any, boundary: bytes, content_length: int, cap_at_buffer: bool = ...
85     ) -> Generator[tuple[str, Any], None, None]: ...
86     def parse_parts(self, file: Any, boundary: bytes, content_length: int) -> Generator[tuple[str, Any], None, None]: ...
87     def parse(self, file: Any, boundary: bytes, content_length: int) -> tuple[_Dict, _Dict]: ...