2 from _typeshed import SupportsGetItem, SupportsItemAccess
3 from builtins import type as _type
4 from collections.abc import Iterable, Iterator, Mapping
5 from typing import IO, Any, Protocol, TypeVar
7 _T = TypeVar("_T", bound=FieldStorage)
10 fp: IO[Any] | None = ...,
11 environ: SupportsItemAccess[str, str] = ...,
12 keep_blank_values: bool = ...,
13 strict_parsing: bool = ...,
15 ) -> dict[str, list[str]]: ...
17 if sys.version_info < (3, 8):
18 def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[str, list[str]]: ...
19 def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> list[tuple[str, str]]: ...
21 if sys.version_info >= (3, 7):
23 fp: IO[Any], pdict: SupportsGetItem[str, bytes], encoding: str = ..., errors: str = ..., separator: str = ...
24 ) -> dict[str, list[Any]]: ...
27 def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> dict[str, list[bytes]]: ...
29 class _Environ(Protocol):
30 def __getitem__(self, __k: str) -> str: ...
31 def keys(self) -> Iterable[str]: ...
33 def parse_header(line: str) -> tuple[str, dict[str, str]]: ...
34 def test(environ: _Environ = ...) -> None: ...
35 def print_environ(environ: _Environ = ...) -> None: ...
36 def print_form(form: dict[str, Any]) -> None: ...
37 def print_directory() -> None: ...
38 def print_environ_usage() -> None: ...
40 if sys.version_info < (3, 8):
41 def escape(s: str, quote: bool | None = ...) -> str: ...
43 class MiniFieldStorage:
44 # The first five "Any" attributes here are always None, but mypy doesn't support that
48 file: IO[bytes] | None
49 type_options: dict[Any, Any]
51 disposition_options: dict[Any, Any]
52 headers: dict[Any, Any]
55 def __init__(self, name: Any, value: Any) -> None: ...
56 def __repr__(self) -> str: ...
60 class FieldStorage(object):
61 FieldStorageClass: _type | None
62 keep_blank_values: int
64 qs_on_post: str | None
65 headers: Mapping[str, str]
73 disposition_options: dict[str, str]
75 file: IO[bytes] | None
77 type_options: dict[str, str]
81 list: _list[Any] | None
82 value: None | bytes | _list[Any]
85 fp: IO[Any] | None = ...,
86 headers: Mapping[str, str] | None = ...,
87 outerboundary: bytes = ...,
88 environ: SupportsGetItem[str, str] = ...,
89 keep_blank_values: int = ...,
90 strict_parsing: int = ...,
91 limit: int | None = ...,
94 max_num_fields: int | None = ...,
97 def __enter__(self: _T) -> _T: ...
98 def __exit__(self, *args: Any) -> None: ...
99 def __repr__(self) -> str: ...
100 def __iter__(self) -> Iterator[str]: ...
101 def __getitem__(self, key: str) -> Any: ...
102 def getvalue(self, key: str, default: Any = ...) -> Any: ...
103 def getfirst(self, key: str, default: Any = ...) -> Any: ...
104 def getlist(self, key: str) -> _list[Any]: ...
105 def keys(self) -> _list[str]: ...
106 def __contains__(self, key: str) -> bool: ...
107 def __len__(self) -> int: ...
108 def __bool__(self) -> bool: ...
109 # In Python 3 it returns bytes or str IO depending on an internal flag
110 def make_file(self) -> IO[Any]: ...