1
1
import sys
2
- from typing import IO , Any , AnyStr , Dict , Iterator , List , Mapping , Optional , Tuple , TypeVar , Union
2
+ from _typeshed import SupportsGetItem , SupportsItemAccess
3
+ from typing import IO , Any , AnyStr , Dict , Iterable , Iterator , List , Mapping , Optional , Protocol , Tuple , TypeVar , Union
3
4
4
5
_T = TypeVar ("_T" , bound = FieldStorage )
5
6
6
7
def parse (
7
- fp : Optional [IO [Any ]] = ..., environ : Mapping [str , str ] = ..., keep_blank_values : bool = ..., strict_parsing : bool = ...
8
+ fp : Optional [IO [Any ]] = ...,
9
+ environ : SupportsItemAccess [str , str ] = ...,
10
+ keep_blank_values : bool = ...,
11
+ strict_parsing : bool = ...,
8
12
) -> Dict [str , List [str ]]: ...
9
13
10
14
if sys .version_info < (3 , 8 ):
@@ -13,15 +17,19 @@ if sys.version_info < (3, 8):
13
17
14
18
if sys .version_info >= (3 , 7 ):
15
19
def parse_multipart (
16
- fp : IO [Any ], pdict : Mapping [str , bytes ], encoding : str = ..., errors : str = ...
20
+ fp : IO [Any ], pdict : SupportsGetItem [str , bytes ], encoding : str = ..., errors : str = ...
17
21
) -> Dict [str , List [Any ]]: ...
18
22
19
23
else :
20
- def parse_multipart (fp : IO [Any ], pdict : Mapping [str , bytes ]) -> Dict [str , List [bytes ]]: ...
24
+ def parse_multipart (fp : IO [Any ], pdict : SupportsGetItem [str , bytes ]) -> Dict [str , List [bytes ]]: ...
25
+
26
+ class _Environ (Protocol ):
27
+ def __getitem__ (self , __k : str ) -> str : ...
28
+ def keys (self ) -> Iterable [str ]: ...
21
29
22
30
def parse_header (line : str ) -> Tuple [str , Dict [str , str ]]: ...
23
- def test (environ : Mapping [ str , str ] = ...) -> None : ...
24
- def print_environ (environ : Mapping [ str , str ] = ...) -> None : ...
31
+ def test (environ : _Environ = ...) -> None : ...
32
+ def print_environ (environ : _Environ = ...) -> None : ...
25
33
def print_form (form : Dict [str , Any ]) -> None : ...
26
34
def print_directory () -> None : ...
27
35
def print_environ_usage () -> None : ...
@@ -77,7 +85,7 @@ class FieldStorage(object):
77
85
fp : Optional [IO [Any ]] = ...,
78
86
headers : Optional [Mapping [str , str ]] = ...,
79
87
outerboundary : bytes = ...,
80
- environ : Mapping [str , str ] = ...,
88
+ environ : SupportsGetItem [str , str ] = ...,
81
89
keep_blank_values : int = ...,
82
90
strict_parsing : int = ...,
83
91
limit : Optional [int ] = ...,
@@ -91,7 +99,7 @@ class FieldStorage(object):
91
99
fp : Optional [IO [Any ]] = ...,
92
100
headers : Optional [Mapping [str , str ]] = ...,
93
101
outerboundary : bytes = ...,
94
- environ : Mapping [str , str ] = ...,
102
+ environ : SupportsGetItem [str , str ] = ...,
95
103
keep_blank_values : int = ...,
96
104
strict_parsing : int = ...,
97
105
limit : Optional [int ] = ...,
@@ -104,7 +112,7 @@ class FieldStorage(object):
104
112
fp : IO [Any ] = ...,
105
113
headers : Mapping [str , str ] = ...,
106
114
outerboundary : bytes = ...,
107
- environ : Mapping [str , str ] = ...,
115
+ environ : SupportsGetItem [str , str ] = ...,
108
116
keep_blank_values : int = ...,
109
117
strict_parsing : int = ...,
110
118
) -> None : ...
0 commit comments