1
1
from datetime import datetime
2
2
from typing import (
3
- Any , Iterable , Mapping , MutableMapping , Optional , Sequence , Tuple , Type ,
4
- Union ,
3
+ Any , Callable , Iterable , Iterator , Mapping , MutableMapping , Optional , Sequence , Text ,
4
+ Tuple , Type , TypeVar , Union ,
5
5
)
6
6
7
7
from wsgiref .types import WSGIEnvironment
@@ -14,13 +14,13 @@ from .datastructures import (
14
14
class BaseRequest :
15
15
charset = ... # type: str
16
16
encoding_errors = ... # type: str
17
- max_content_length = ... # type: Union[ int, long]
18
- max_form_memory_size = ... # type: Union[ int, long]
17
+ max_content_length = ... # type: int
18
+ max_form_memory_size = ... # type: int
19
19
parameter_storage_class = ... # type: Type
20
20
list_storage_class = ... # type: Type
21
21
dict_storage_class = ... # type: Type
22
22
form_data_parser_class = ... # type: Type
23
- trusted_hosts = ... # type: Optional[Sequence[unicode ]]
23
+ trusted_hosts = ... # type: Optional[Sequence[Text ]]
24
24
disable_data_descriptor = ... # type: Any
25
25
environ : WSGIEnvironment = ...
26
26
shallow = ... # type: Any
@@ -41,34 +41,37 @@ class BaseRequest:
41
41
input_stream = ... # type: Any
42
42
args = ... # type: ImmutableMultiDict
43
43
@property
44
- def data (self ) -> str : ...
45
- def get_data (self , cache : bool = ..., as_text : bool = ..., parse_form_data : bool = ...) -> str : ...
44
+ def data (self ) -> bytes : ...
45
+ def get_data (self , cache : bool = ..., as_text : bool = ..., parse_form_data : bool = ...) -> bytes : ...
46
46
form = ... # type: ImmutableMultiDict
47
47
values = ... # type: CombinedMultiDict
48
48
files = ... # type: MultiDict
49
49
cookies = ... # type: TypeConversionDict
50
50
headers = ... # type: EnvironHeaders
51
- path = ... # type: unicode
52
- full_path = ... # type: unicode
53
- script_root = ... # type: unicode
54
- url = ... # type: unicode
55
- base_url = ... # type: unicode
56
- url_root = ... # type: unicode
57
- host_url = ... # type: unicode
58
- host = ... # type: unicode
59
- query_string = ... # type: str
60
- method = ... # type: str
51
+ path = ... # type: Text
52
+ full_path = ... # type: Text
53
+ script_root = ... # type: Text
54
+ url = ... # type: Text
55
+ base_url = ... # type: Text
56
+ url_root = ... # type: Text
57
+ host_url = ... # type: Text
58
+ host = ... # type: Text
59
+ query_string = ... # type: bytes
60
+ method = ... # type: Text
61
61
def access_route (self ): ...
62
62
@property
63
63
def remote_addr (self ) -> str : ...
64
- remote_user = ... # type: unicode
64
+ remote_user = ... # type: Text
65
65
scheme = ... # type: str
66
66
is_xhr = ... # type: bool
67
67
is_secure = ... # type: bool
68
68
is_multithread = ... # type: bool
69
69
is_multiprocess = ... # type: bool
70
70
is_run_once = ... # type: bool
71
71
72
+ _OnCloseT = TypeVar ('_OnCloseT' , bound = Callable [[], Any ])
73
+ _SelfT = TypeVar ('_SelfT' , bound = BaseResponse )
74
+
72
75
class BaseResponse :
73
76
charset = ... # type: str
74
77
default_status = ... # type: int
@@ -80,27 +83,26 @@ class BaseResponse:
80
83
status_code = ... # type: int
81
84
status = ... # type: str
82
85
direct_passthrough = ... # type: bool
83
- response = ... # type: Iterable[str]
84
- def __init__ (self ,
85
- response : Optional [Union [Iterable [str ], str ]] = ...,
86
- status : Optional [Union [basestring , int ]] = ...,
86
+ response = ... # type: Iterable[bytes]
87
+ def __init__ (self , response : Optional [Union [Iterable [bytes ], bytes ]] = ...,
88
+ status : Optional [Union [Text , int ]] = ...,
87
89
headers : Optional [Union [Headers ,
88
- Mapping [basestring , basestring ],
89
- Sequence [Tuple [basestring , basestring ]]]] = None ,
90
- mimetype : Optional [basestring ] = ...,
91
- content_type : Optional [basestring ] = ...,
92
- direct_passthrough : Optional [ bool ] = ...) -> None : ...
93
- def call_on_close (self , func ) : ...
90
+ Mapping [Text , Text ],
91
+ Sequence [Tuple [Text , Text ]]]] = ... ,
92
+ mimetype : Optional [Text ] = ...,
93
+ content_type : Optional [Text ] = ...,
94
+ direct_passthrough : bool = ...) -> None : ...
95
+ def call_on_close (self , func : _OnCloseT ) -> _OnCloseT : ...
94
96
@classmethod
95
- def force_type (cls , response , environ = None ) : ...
97
+ def force_type (cls : Type [ _SelfT ] , response : object , environ : Optional [ WSGIEnvironment ] = ...) -> _SelfT : ...
96
98
@classmethod
97
- def from_app (cls , app , environ , buffered = False ) : ...
98
- def get_data (self , as_text = False ) : ...
99
- def set_data (self , value ) : ...
99
+ def from_app (cls : Type [ _SelfT ] , app : Any , environ : WSGIEnvironment , buffered : bool = ...) -> _SelfT : ...
100
+ def get_data (self , as_text : bool = ...) -> Any : ... # returns bytes if as_text is False (the default), else Text
101
+ def set_data (self , value : Union [ bytes , Text ]) -> None : ...
100
102
data = ... # type: Any
101
- def calculate_content_length (self ): ...
102
- def make_sequence (self ): ...
103
- def iter_encoded (self ): ...
103
+ def calculate_content_length (self ) -> Optional [ int ] : ...
104
+ def make_sequence (self ) -> None : ...
105
+ def iter_encoded (self ) -> Iterator [ bytes ] : ...
104
106
def set_cookie (self , key , value = '' , max_age = None , expires = None , path = '' , domain = None , secure = False , httponly = False ): ...
105
107
def delete_cookie (self , key , path = '' , domain = None ): ...
106
108
@property
0 commit comments