11import 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
34
45_T = TypeVar ("_T" , bound = FieldStorage )
56
67def 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 = ...,
812) -> Dict [str , List [str ]]: ...
913
1014if sys .version_info < (3 , 8 ):
@@ -13,15 +17,19 @@ if sys.version_info < (3, 8):
1317
1418if sys .version_info >= (3 , 7 ):
1519 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 = ...
1721 ) -> Dict [str , List [Any ]]: ...
1822
1923else :
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 ]: ...
2129
2230def 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 : ...
2533def print_form (form : Dict [str , Any ]) -> None : ...
2634def print_directory () -> None : ...
2735def print_environ_usage () -> None : ...
@@ -77,7 +85,7 @@ class FieldStorage(object):
7785 fp : Optional [IO [Any ]] = ...,
7886 headers : Optional [Mapping [str , str ]] = ...,
7987 outerboundary : bytes = ...,
80- environ : Mapping [str , str ] = ...,
88+ environ : SupportsGetItem [str , str ] = ...,
8189 keep_blank_values : int = ...,
8290 strict_parsing : int = ...,
8391 limit : Optional [int ] = ...,
@@ -91,7 +99,7 @@ class FieldStorage(object):
9199 fp : Optional [IO [Any ]] = ...,
92100 headers : Optional [Mapping [str , str ]] = ...,
93101 outerboundary : bytes = ...,
94- environ : Mapping [str , str ] = ...,
102+ environ : SupportsGetItem [str , str ] = ...,
95103 keep_blank_values : int = ...,
96104 strict_parsing : int = ...,
97105 limit : Optional [int ] = ...,
@@ -104,7 +112,7 @@ class FieldStorage(object):
104112 fp : IO [Any ] = ...,
105113 headers : Mapping [str , str ] = ...,
106114 outerboundary : bytes = ...,
107- environ : Mapping [str , str ] = ...,
115+ environ : SupportsGetItem [str , str ] = ...,
108116 keep_blank_values : int = ...,
109117 strict_parsing : int = ...,
110118 ) -> None : ...
0 commit comments