-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathsessions.pyi
240 lines (230 loc) · 8.54 KB
/
sessions.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
from _typeshed import Self, SupportsItems
from collections.abc import Callable, Iterable, Mapping, MutableMapping
from typing import IO, Any, Union
from typing_extensions import TypeAlias
from urllib3._collections import RecentlyUsedContainer
from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, utils
from .models import Response
from .structures import CaseInsensitiveDict as CaseInsensitiveDict
_BaseAdapter: TypeAlias = adapters.BaseAdapter
OrderedDict = compat.OrderedDict
cookiejar_from_dict = cookies.cookiejar_from_dict
extract_cookies_to_jar = cookies.extract_cookies_to_jar
RequestsCookieJar = cookies.RequestsCookieJar
merge_cookies = cookies.merge_cookies
Request = models.Request
PreparedRequest = models.PreparedRequest
DEFAULT_REDIRECT_LIMIT = models.DEFAULT_REDIRECT_LIMIT
default_hooks = hooks.default_hooks
dispatch_hook = hooks.dispatch_hook
to_key_val_list = utils.to_key_val_list
default_headers = utils.default_headers
to_native_string = utils.to_native_string
TooManyRedirects = exceptions.TooManyRedirects
InvalidSchema = exceptions.InvalidSchema
ChunkedEncodingError = exceptions.ChunkedEncodingError
ContentDecodingError = exceptions.ContentDecodingError
HTTPAdapter = adapters.HTTPAdapter
requote_uri = utils.requote_uri
get_environ_proxies = utils.get_environ_proxies
get_netrc_auth = utils.get_netrc_auth
should_bypass_proxies = utils.should_bypass_proxies
get_auth_from_url = utils.get_auth_from_url
codes = status_codes.codes
REDIRECT_STATI = models.REDIRECT_STATI
def merge_setting(request_setting, session_setting, dict_class=...): ...
def merge_hooks(request_hooks, session_hooks, dict_class=...): ...
class SessionRedirectMixin:
def resolve_redirects(self, resp, req, stream=..., timeout=..., verify=..., cert=..., proxies=...): ...
def rebuild_auth(self, prepared_request, response): ...
def rebuild_proxies(self, prepared_request, proxies): ...
def should_strip_auth(self, old_url, new_url): ...
_Data: TypeAlias = str | bytes | Mapping[str, Any] | Iterable[tuple[str, str | None]] | IO[Any] | None
_Hook: TypeAlias = Callable[[Response], Any]
_Hooks: TypeAlias = MutableMapping[str, _Hook | list[_Hook]]
_HooksInput: TypeAlias = MutableMapping[str, Iterable[_Hook] | _Hook]
_ParamsMappingKeyType: TypeAlias = str | bytes | int | float
_ParamsMappingValueType: TypeAlias = str | bytes | int | float | Iterable[str | bytes | int | float] | None
_Params: TypeAlias = Union[
SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType],
tuple[_ParamsMappingKeyType, _ParamsMappingValueType],
Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]],
str | bytes,
]
_TextMapping: TypeAlias = MutableMapping[str, str]
class Session(SessionRedirectMixin):
__attrs__: Any
headers: CaseInsensitiveDict[str]
auth: None | tuple[str, str] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest]
proxies: _TextMapping
hooks: _Hooks
params: _Params
stream: bool
verify: None | bool | str
cert: None | str | tuple[str, str]
max_redirects: int
trust_env: bool
cookies: RequestsCookieJar
adapters: MutableMapping[Any, Any]
redirect_cache: RecentlyUsedContainer[Any, Any]
def __init__(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, *args) -> None: ...
def prepare_request(self, request: Request) -> PreparedRequest: ...
def request(
self,
method: str,
url: str | bytes,
params: _Params | None = ...,
data: _Data = ...,
headers: _TextMapping | None = ...,
cookies: None | RequestsCookieJar | _TextMapping = ...,
files: MutableMapping[str, IO[Any]]
| MutableMapping[str, tuple[str, IO[Any]]]
| MutableMapping[str, tuple[str, IO[Any], str]]
| MutableMapping[str, tuple[str, IO[Any], str, _TextMapping]]
| None = ...,
auth: None | tuple[str, str] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest] = ...,
timeout: None | float | tuple[float, float] | tuple[float, None] = ...,
allow_redirects: bool | None = ...,
proxies: _TextMapping | None = ...,
hooks: _HooksInput | None = ...,
stream: bool | None = ...,
verify: None | bool | str = ...,
cert: str | tuple[str, str] | None = ...,
json: Any | None = ...,
) -> Response: ...
def get(
self,
url: str | bytes,
params: _Params | None = ...,
data: Any | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
json: Any | None = ...,
) -> Response: ...
def options(
self,
url: str | bytes,
params: _Params | None = ...,
data: Any | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
json: Any | None = ...,
) -> Response: ...
def head(
self,
url: str | bytes,
params: _Params | None = ...,
data: Any | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
json: Any | None = ...,
) -> Response: ...
def post(
self,
url: str | bytes,
data: _Data = ...,
json: Any | None = ...,
params: _Params | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
) -> Response: ...
def put(
self,
url: str | bytes,
data: _Data = ...,
params: _Params | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
json: Any | None = ...,
) -> Response: ...
def patch(
self,
url: str | bytes,
data: _Data = ...,
params: _Params | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
json: Any | None = ...,
) -> Response: ...
def delete(
self,
url: str | bytes,
params: _Params | None = ...,
data: Any | None = ...,
headers: Any | None = ...,
cookies: Any | None = ...,
files: Any | None = ...,
auth: Any | None = ...,
timeout: Any | None = ...,
allow_redirects: bool = ...,
proxies: Any | None = ...,
hooks: Any | None = ...,
stream: Any | None = ...,
verify: Any | None = ...,
cert: Any | None = ...,
json: Any | None = ...,
) -> Response: ...
def send(
self, request: PreparedRequest, *, stream=..., verify=..., cert=..., proxies=..., allow_redirects: bool = ..., **kwargs
) -> Response: ...
def merge_environment_settings(self, url, proxies, stream, verify, cert): ...
def get_adapter(self, url: str) -> _BaseAdapter: ...
def close(self) -> None: ...
def mount(self, prefix: str | bytes, adapter: _BaseAdapter) -> None: ...
def session() -> Session: ...