pyreqwest 0.5.0__cp314-cp314-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyreqwest might be problematic. Click here for more details.

Files changed (41) hide show
  1. pyreqwest/__init__.py +3 -0
  2. pyreqwest/__init__.pyi +1 -0
  3. pyreqwest/_pyreqwest.cp314-win_arm64.pyd +0 -0
  4. pyreqwest/bytes/__init__.py +16 -0
  5. pyreqwest/bytes/__init__.pyi +106 -0
  6. pyreqwest/client/__init__.py +21 -0
  7. pyreqwest/client/__init__.pyi +341 -0
  8. pyreqwest/client/types.py +54 -0
  9. pyreqwest/cookie/__init__.py +5 -0
  10. pyreqwest/cookie/__init__.pyi +174 -0
  11. pyreqwest/exceptions/__init__.py +193 -0
  12. pyreqwest/http/__init__.py +19 -0
  13. pyreqwest/http/__init__.pyi +344 -0
  14. pyreqwest/middleware/__init__.py +5 -0
  15. pyreqwest/middleware/__init__.pyi +12 -0
  16. pyreqwest/middleware/asgi/__init__.py +5 -0
  17. pyreqwest/middleware/asgi/asgi.py +168 -0
  18. pyreqwest/middleware/types.py +26 -0
  19. pyreqwest/multipart/__init__.py +5 -0
  20. pyreqwest/multipart/__init__.pyi +75 -0
  21. pyreqwest/proxy/__init__.py +5 -0
  22. pyreqwest/proxy/__init__.pyi +47 -0
  23. pyreqwest/py.typed +0 -0
  24. pyreqwest/pytest_plugin/__init__.py +8 -0
  25. pyreqwest/pytest_plugin/internal/__init__.py +0 -0
  26. pyreqwest/pytest_plugin/internal/assert_eq.py +6 -0
  27. pyreqwest/pytest_plugin/internal/assert_message.py +123 -0
  28. pyreqwest/pytest_plugin/internal/matcher.py +34 -0
  29. pyreqwest/pytest_plugin/internal/plugin.py +15 -0
  30. pyreqwest/pytest_plugin/mock.py +493 -0
  31. pyreqwest/pytest_plugin/types.py +26 -0
  32. pyreqwest/request/__init__.py +25 -0
  33. pyreqwest/request/__init__.pyi +200 -0
  34. pyreqwest/response/__init__.py +19 -0
  35. pyreqwest/response/__init__.pyi +157 -0
  36. pyreqwest/types.py +12 -0
  37. pyreqwest-0.5.0.dist-info/METADATA +106 -0
  38. pyreqwest-0.5.0.dist-info/RECORD +41 -0
  39. pyreqwest-0.5.0.dist-info/WHEEL +4 -0
  40. pyreqwest-0.5.0.dist-info/entry_points.txt +2 -0
  41. pyreqwest-0.5.0.dist-info/licenses/LICENSE +201 -0
pyreqwest/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """.. include:: ../../README.md"""
2
+
3
+ from ._pyreqwest import __version__ # noqa: F401
pyreqwest/__init__.pyi ADDED
@@ -0,0 +1 @@
1
+ __version__: str
Binary file
@@ -0,0 +1,16 @@
1
+ """Buffer protocol implementation."""
2
+
3
+ from pyreqwest._pyreqwest.bytes import Bytes
4
+
5
+ Bytes.__doc__ = """A `bytes`-like buffer.
6
+
7
+ This implements the Python buffer protocol, allowing zero-copy access
8
+ to underlying Rust memory.
9
+
10
+ You can pass this to `memoryview` for a zero-copy view into the underlying
11
+ data or to `bytes` to copy the underlying data into a Python `bytes`.
12
+
13
+ Many methods from the Python `bytes` class are implemented on this,
14
+ """
15
+
16
+ __all__ = ["Bytes"]
@@ -0,0 +1,106 @@
1
+ # Based on:
2
+ # https://github.com/developmentseed/obstore/blob/b87054eaac3a26ee65a1d4bc69a5e01fdab3d5d9/pyo3-bytes/README.md?plain=1#L58
3
+
4
+ import sys
5
+ from typing import Protocol, Self, overload
6
+
7
+ if sys.version_info >= (3, 12):
8
+ from collections.abc import Buffer
9
+ else:
10
+ class Buffer(Protocol):
11
+ # Not actually a Protocol at runtime; see https://github.com/python/typeshed/issues/10224
12
+ def __buffer__(self, flags: int, /) -> memoryview: ...
13
+
14
+ class Bytes(Buffer):
15
+ """A `bytes`-like buffer.
16
+
17
+ This implements the Python buffer protocol, allowing zero-copy access
18
+ to underlying Rust memory.
19
+
20
+ You can pass this to `memoryview` for a zero-copy view into the underlying
21
+ data or to `bytes` to copy the underlying data into a Python `bytes`.
22
+ You can also use `to_bytes` to copy the underlying data into a Python `bytes`.
23
+
24
+ Many methods from the Python `bytes` class are implemented on this,
25
+ """
26
+
27
+ def __init__(self, buf: Buffer = b"") -> None:
28
+ """Construct a new Bytes object.
29
+
30
+ This will be a zero-copy view on the Python byte slice.
31
+ """
32
+ def __add__(self, other: Buffer) -> Self: ...
33
+ def __buffer__(self, flags: int) -> memoryview: ...
34
+ def __contains__(self, other: Buffer) -> bool: ...
35
+ def __eq__(self, other: object) -> bool: ...
36
+ @overload
37
+ def __getitem__(self, key: int, /) -> int: ...
38
+ @overload
39
+ def __getitem__(self, key: slice, /) -> Self: ...
40
+ def __getitem__(self, key: int | slice, /) -> int | Self: ... # type: ignore[misc] # docstring in pyi file
41
+ def __mul__(self, other: Buffer) -> int: ...
42
+ def __len__(self) -> int: ...
43
+ def removeprefix(self, prefix: Buffer, /) -> Self:
44
+ """If the binary data starts with the prefix string, return `bytes[len(prefix):]`.
45
+ Otherwise, return the original binary data.
46
+ """
47
+ def removesuffix(self, suffix: Buffer, /) -> Self:
48
+ """If the binary data ends with the suffix string and that suffix is not empty,
49
+ return `bytes[:-len(suffix)]`. Otherwise, return the original binary data.
50
+ """
51
+ def isalnum(self) -> bool:
52
+ """Return `True` if all bytes in the sequence are alphabetical ASCII characters or
53
+ ASCII decimal digits and the sequence is not empty, `False` otherwise.
54
+
55
+ Alphabetic ASCII characters are those byte values in the sequence
56
+ `b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`. ASCII decimal digits
57
+ are those byte values in the sequence `b'0123456789'`.
58
+ """
59
+ def isalpha(self) -> bool:
60
+ """Return `True` if all bytes in the sequence are alphabetic ASCII characters and
61
+ the sequence is not empty, `False` otherwise.
62
+
63
+ Alphabetic ASCII characters are those byte values in the sequence
64
+ `b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`.
65
+ """
66
+ def isascii(self) -> bool:
67
+ """Return `True` if the sequence is empty or all bytes in the sequence are ASCII,
68
+ `False` otherwise.
69
+
70
+ ASCII bytes are in the range `0-0x7F`.
71
+ """
72
+ def isdigit(self) -> bool:
73
+ """Return `True` if all bytes in the sequence are ASCII decimal digits and the
74
+ sequence is not empty, `False` otherwise.
75
+
76
+ ASCII decimal digits are those byte values in the sequence `b'0123456789'`.
77
+ """
78
+ def islower(self) -> bool:
79
+ """Return `True` if there is at least one lowercase ASCII character in the sequence
80
+ and no uppercase ASCII characters, `False` otherwise.
81
+ """
82
+ def isspace(self) -> bool:
83
+ r"""Return `True` if all bytes in the sequence are ASCII whitespace and the sequence
84
+ is not empty, `False` otherwise.
85
+
86
+ ASCII whitespace characters are those byte values
87
+ in the sequence `b' \t\n\r\x0b\f'` (space, tab, newline, carriage return,
88
+ vertical tab, form feed).
89
+ """
90
+ def isupper(self) -> bool:
91
+ """Return `True` if there is at least one uppercase alphabetic ASCII character in
92
+ the sequence and no lowercase ASCII characters, `False` otherwise.
93
+ """
94
+
95
+ def lower(self) -> Self:
96
+ """Return a copy of the sequence with all the uppercase ASCII characters converted
97
+ to their corresponding lowercase counterpart.
98
+ """
99
+
100
+ def upper(self) -> Self:
101
+ """Return a copy of the sequence with all the lowercase ASCII characters converted
102
+ to their corresponding uppercase counterpart.
103
+ """
104
+
105
+ def to_bytes(self) -> bytes:
106
+ """Copy this buffer's contents into a Python `bytes` object."""
@@ -0,0 +1,21 @@
1
+ """Client classes and builders."""
2
+
3
+ from pyreqwest._pyreqwest.client import (
4
+ BaseClient,
5
+ BaseClientBuilder,
6
+ Client,
7
+ ClientBuilder,
8
+ Runtime,
9
+ SyncClient,
10
+ SyncClientBuilder,
11
+ )
12
+
13
+ __all__ = [ # noqa: RUF022
14
+ "Client",
15
+ "ClientBuilder",
16
+ "SyncClient",
17
+ "SyncClientBuilder",
18
+ "BaseClient",
19
+ "BaseClientBuilder",
20
+ "Runtime",
21
+ ]
@@ -0,0 +1,341 @@
1
+ """HTTP client interfaces (async + sync) modeled after Rust reqwest.
2
+
3
+ `Client`/`SyncClient` is created via `ClientBuilder`/`SyncClientBuilder`.
4
+ Client should be reused for multiple requests.
5
+ """
6
+
7
+ from datetime import timedelta
8
+ from typing import Any, Self
9
+
10
+ from pyreqwest.cookie import CookieStore
11
+ from pyreqwest.http import Url
12
+ from pyreqwest.middleware.types import Middleware, SyncMiddleware
13
+ from pyreqwest.proxy import ProxyBuilder
14
+ from pyreqwest.request import RequestBuilder, SyncRequestBuilder
15
+ from pyreqwest.types import HeadersType
16
+
17
+ from .types import JsonDumps, JsonLoads, SyncJsonLoads, TlsVersion
18
+
19
+ class BaseClient:
20
+ """Common base for async and sync clients."""
21
+
22
+ class Client(BaseClient):
23
+ """Asynchronous HTTP client. Inspired by reqwest's Client.
24
+
25
+ Use as an async context manager for graceful shutdown. Can be also manually closed. Reuse for multiple requests.
26
+ See also Rust reqwest [docs](https://docs.rs/reqwest/latest/reqwest/struct.Client.html) for more details.
27
+ """
28
+
29
+ async def __aenter__(self) -> Self:
30
+ """Enter the async context manager (just returns self). @public"""
31
+
32
+ async def __aexit__(self, *args: object, **kwargs: Any) -> None:
33
+ """Close the client. @public"""
34
+
35
+ def request(self, method: str, url: Url | str) -> RequestBuilder:
36
+ """Start building a request with the method and url.
37
+
38
+ Returns a request builder, which will allow setting headers and the request body before sending.
39
+ """
40
+
41
+ def get(self, url: Url | str) -> RequestBuilder:
42
+ """Same as `request("GET", url)`."""
43
+
44
+ def post(self, url: Url | str) -> RequestBuilder:
45
+ """Same as `request("POST", url)`."""
46
+
47
+ def put(self, url: Url | str) -> RequestBuilder:
48
+ """Same as `request("PUT", url)`."""
49
+
50
+ def patch(self, url: Url | str) -> RequestBuilder:
51
+ """Same as `request("PATCH", url)`."""
52
+
53
+ def delete(self, url: Url | str) -> RequestBuilder:
54
+ """Same as `request("DELETE", url)`."""
55
+
56
+ def head(self, url: Url | str) -> RequestBuilder:
57
+ """Same as `request("HEAD", url)`."""
58
+
59
+ async def close(self) -> None:
60
+ """Close the client."""
61
+
62
+ class SyncClient(BaseClient):
63
+ """Synchronous HTTP client. Inspired by reqwest's Client.
64
+
65
+ Use as a context manager for graceful shutdown. Can be also manually closed. Reuse for multiple requests.
66
+ See also Rust reqwest [docs](https://docs.rs/reqwest/latest/reqwest/struct.Client.html) for more details.
67
+ """
68
+
69
+ def __enter__(self) -> Self:
70
+ """Enter the context manager (just returns self). @public"""
71
+
72
+ def __exit__(self, *args: object, **kwargs: Any) -> None:
73
+ """Exit the context manager and close resources. @public"""
74
+
75
+ def request(self, method: str, url: Url | str) -> SyncRequestBuilder:
76
+ """Start building a request with the method and url.
77
+
78
+ Returns a request builder, which will allow setting headers and the request body before sending.
79
+ """
80
+
81
+ def get(self, url: Url | str) -> SyncRequestBuilder:
82
+ """Same as `request("GET", url)`."""
83
+
84
+ def post(self, url: Url | str) -> SyncRequestBuilder:
85
+ """Same as `request("POST", url)`."""
86
+
87
+ def put(self, url: Url | str) -> SyncRequestBuilder:
88
+ """Same as `request("PUT", url)`."""
89
+
90
+ def patch(self, url: Url | str) -> SyncRequestBuilder:
91
+ """Same as `request("PATCH", url)`."""
92
+
93
+ def delete(self, url: Url | str) -> SyncRequestBuilder:
94
+ """Same as `request("DELETE", url)`."""
95
+
96
+ def head(self, url: Url | str) -> SyncRequestBuilder:
97
+ """Same as `request("HEAD", url)`."""
98
+
99
+ def close(self) -> None:
100
+ """Close the client."""
101
+
102
+ class BaseClientBuilder:
103
+ def base_url(self, url: Url | str) -> Self:
104
+ """Set a base URL automatically prepended to relative request URLs."""
105
+
106
+ def runtime(self, runtime: "Runtime") -> Self:
107
+ """Use a custom runtime (advanced scenarios). Usually not needed. By default, a global runtime is used."""
108
+
109
+ def max_connections(self, max_connections: int | None) -> Self:
110
+ """Maximum number of inflight requests. None means no limit. Default is None."""
111
+
112
+ def error_for_status(self, enable: bool) -> Self:
113
+ """Enable automatic HTTP error raising (4xx/5xx)."""
114
+
115
+ def user_agent(self, value: str) -> Self:
116
+ """Sets the User-Agent header to be used by this client (unless overridden).
117
+ Default is `python-pyreqwest/1.0.0`.
118
+ """
119
+
120
+ def default_headers(self, headers: HeadersType) -> Self:
121
+ """Sets the default headers for every request (unless overridden)."""
122
+
123
+ def default_cookie_store(self, enable: bool) -> Self:
124
+ """Enables default in-memory cookie store. Same as `cookie_store` in reqwest. Default is false."""
125
+
126
+ def cookie_provider(self, provider: CookieStore) -> Self:
127
+ """Set the cookie store for the client. Overrides `default_cookie_store`."""
128
+
129
+ def gzip(self, enable: bool) -> Self:
130
+ """Enable auto gzip decompression. Default is true."""
131
+
132
+ def brotli(self, enable: bool) -> Self:
133
+ """Enable auto brotli decompression. Default is true."""
134
+
135
+ def zstd(self, enable: bool) -> Self:
136
+ """Enable auto zstd decompression. Default is true."""
137
+
138
+ def deflate(self, enable: bool) -> Self:
139
+ """Enable auto deflate decompression. Default is true."""
140
+
141
+ def max_redirects(self, max_redirects: int) -> Self:
142
+ """Set maximum number of followed redirects. Default will follow redirects up to a maximum of 10."""
143
+
144
+ def referer(self, enable: bool) -> Self:
145
+ """Enable or disable automatic setting of the Referer header. Default is true."""
146
+
147
+ def proxy(self, proxy: ProxyBuilder) -> Self:
148
+ """Add a proxy based on ProxyBuilder to the list of proxies the Client will use."""
149
+
150
+ def no_proxy(self) -> Self:
151
+ """Clear all Proxies, so Client will use no proxy anymore."""
152
+
153
+ def timeout(self, timeout: timedelta) -> Self:
154
+ """Enables a total request timeout. Default is no timeout.
155
+
156
+ The timeout is applied from when the request starts connecting until the response body has finished.
157
+ Also considered a total deadline.
158
+ """
159
+
160
+ def read_timeout(self, timeout: timedelta) -> Self:
161
+ """Enables a read timeout. Default is no timeout.
162
+
163
+ The timeout applies to each read operation, and resets after a successful read. This is more appropriate for
164
+ detecting stalled connections when the size isn't known beforehand.
165
+ """
166
+
167
+ def connect_timeout(self, timeout: timedelta) -> Self:
168
+ """Set a timeout for only the connect phase of a Client. Default is None."""
169
+
170
+ def pool_timeout(self, timeout: timedelta) -> Self:
171
+ """Max wait time for an idle connection slot."""
172
+
173
+ def pool_idle_timeout(self, timeout: timedelta | None) -> Self:
174
+ """Set an optional timeout for idle sockets being kept-alive. Default is 90 seconds."""
175
+
176
+ def pool_max_idle_per_host(self, max_idle: int) -> Self:
177
+ """Sets the maximum idle connection per host allowed in the pool."""
178
+
179
+ def http1_lower_case_headers(self) -> Self:
180
+ """Send headers as lowercase instead of title case. Default is false.
181
+
182
+ This differs from reqwest which uses lowercase by default.
183
+ """
184
+
185
+ def http1_allow_obsolete_multiline_headers_in_responses(self, value: bool) -> Self:
186
+ """Set whether HTTP/1 connections will accept obsolete line folding for header values.
187
+
188
+ Newline codepoints will be transformed to spaces when parsing.
189
+ """
190
+
191
+ def http1_ignore_invalid_headers_in_responses(self, value: bool) -> Self:
192
+ """Sets whether invalid header lines should be silently ignored in HTTP/1 responses."""
193
+
194
+ def http1_allow_spaces_after_header_name_in_responses(self, value: bool) -> Self:
195
+ """Set whether HTTP/1 accepts spaces between header names and the colon that follow them in responses.
196
+
197
+ Newline codepoints will be transformed to spaces when parsing.
198
+ """
199
+
200
+ def http1_only(self) -> Self:
201
+ """Only use HTTP/1."""
202
+
203
+ def http09_responses(self) -> Self:
204
+ """Allow HTTP/0.9 responses (very old / uncommon)."""
205
+
206
+ def http2_prior_knowledge(self) -> Self:
207
+ """Only use HTTP/2."""
208
+
209
+ def http2_initial_stream_window_size(self, value: int | None) -> Self:
210
+ """Sets the SETTINGS_INITIAL_WINDOW_SIZE option for HTTP2 stream-level flow control. Default is 65K."""
211
+
212
+ def http2_initial_connection_window_size(self, value: int | None) -> Self:
213
+ """Sets the max connection-level flow control for HTTP2. Default is currently 65K."""
214
+
215
+ def http2_adaptive_window(self, enabled: bool) -> Self:
216
+ """Sets whether to use an adaptive flow control."""
217
+
218
+ def http2_max_frame_size(self, value: int | None) -> Self:
219
+ """Sets the maximum frame size to use for HTTP2. Default is currently 16K."""
220
+
221
+ def http2_max_header_list_size(self, value: int) -> Self:
222
+ """Sets the maximum size of received header frames for HTTP2. Default is currently 16KB."""
223
+
224
+ def http2_keep_alive_interval(self, value: timedelta | None) -> Self:
225
+ """Sets an interval for HTTP2 Ping frames should be sent to keep a connection alive. Default is disabled."""
226
+
227
+ def http2_keep_alive_timeout(self, timeout: timedelta) -> Self:
228
+ """Sets a timeout for receiving an acknowledgement of the keep-alive ping. Default is disabled."""
229
+
230
+ def http2_keep_alive_while_idle(self, enabled: bool) -> Self:
231
+ """Sets whether HTTP2 keep-alive should apply while the connection is idle. Default is false."""
232
+
233
+ def tcp_nodelay(self, enabled: bool) -> Self:
234
+ """Set TCP_NODELAY (disable Nagle). Default is true."""
235
+
236
+ def local_address(self, addr: str | None) -> Self:
237
+ """Bind to a local IP Address."""
238
+
239
+ def interface(self, value: str) -> Self:
240
+ """Bind connections only on the specified network interface."""
241
+
242
+ def tcp_keepalive(self, duration: timedelta | None) -> Self:
243
+ """Set SO_KEEPALIVE duration (overall TCP keepalive time)."""
244
+
245
+ def tcp_keepalive_interval(self, interval: timedelta | None) -> Self:
246
+ """Set SO_KEEPALIVE interval (TCP keepalive probe interval)."""
247
+
248
+ def tcp_keepalive_retries(self, count: int | None) -> Self:
249
+ """Set SO_KEEPALIVE retry count (number of failed keepalive probes before drop)."""
250
+
251
+ def tcp_user_timeout(self, timeout: timedelta | None) -> Self:
252
+ """Set TCP_USER_TIMEOUT (how long data may remain unacknowledged before the connection is force-closed)."""
253
+
254
+ def add_root_certificate_der(self, cert: bytes) -> Self:
255
+ """Trust additional DER root certificate."""
256
+
257
+ def add_root_certificate_pem(self, cert: bytes) -> Self:
258
+ """Trust additional PEM root certificate."""
259
+
260
+ def add_crl_pem(self, cert: bytes) -> Self:
261
+ """Add a certificate revocation list from PEM data."""
262
+
263
+ def tls_built_in_root_certs(self, enable: bool) -> Self:
264
+ """Toggle built-in root cert usage. Defaults to true - built-in system certs will be used."""
265
+
266
+ def identity_pem(self, buf: bytes) -> Self:
267
+ """Sets the identity to be used for client certificate authentication."""
268
+
269
+ def danger_accept_invalid_hostnames(self, enable: bool) -> Self:
270
+ """Disable hostname verification (INSECURE). Defaults to false."""
271
+
272
+ def danger_accept_invalid_certs(self, enable: bool) -> Self:
273
+ """Disable certificate validation (INSECURE). Defaults to false."""
274
+
275
+ def tls_sni(self, enable: bool) -> Self:
276
+ """Enable / disable TLS server name indication. Defaults to true."""
277
+
278
+ def min_tls_version(self, value: TlsVersion) -> Self:
279
+ """Set minimum accepted TLS version."""
280
+
281
+ def max_tls_version(self, value: TlsVersion) -> Self:
282
+ """Set maximum accepted TLS version."""
283
+
284
+ def https_only(self, enable: bool) -> Self:
285
+ """Refuse plain HTTP (HTTPS required). Defaults to false."""
286
+
287
+ def resolve(self, domain: str, ip: str, port: int) -> Self:
288
+ """Add static DNS resolution mapping (domain -> ip:port)."""
289
+
290
+ class ClientBuilder(BaseClientBuilder):
291
+ """Fluent builder for configuring an async `Client`.
292
+
293
+ After configuring options, call `build()` to obtain a `Client`.
294
+ See also Rust reqwest [docs](https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html) for more details.
295
+ """
296
+
297
+ def __init__(self) -> None:
298
+ """Create a new builder with default settings."""
299
+
300
+ def build(self) -> Client:
301
+ """Finalize and construct the async client.
302
+
303
+ Fails if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.
304
+ """
305
+
306
+ def with_middleware(self, middleware: Middleware) -> Self:
307
+ """Register a middleware component (executed in chain order)."""
308
+
309
+ def json_handler(self, *, loads: JsonLoads | None = ..., dumps: JsonDumps | None = ...) -> Self:
310
+ """Override JSON loads / dumps callables for this client."""
311
+
312
+ class SyncClientBuilder(BaseClientBuilder):
313
+ """Fluent builder for configuring a synchronous `SyncClient` (blocking style).
314
+
315
+ After configuring options, call `build()` to obtain a `Client`.
316
+ See also Rust reqwest [docs](https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html) for more details.
317
+ """
318
+
319
+ def __init__(self) -> None:
320
+ """Create a new builder with default settings."""
321
+
322
+ def build(self) -> SyncClient:
323
+ """Finalize and construct the sync client.
324
+
325
+ Fails if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.
326
+ """
327
+
328
+ def with_middleware(self, middleware: SyncMiddleware) -> Self:
329
+ """Register a middleware component (executed in chain order)."""
330
+
331
+ def json_handler(self, *, loads: SyncJsonLoads | None = ..., dumps: JsonDumps | None = ...) -> Self:
332
+ """Override JSON loads / dumps callables for this sync client."""
333
+
334
+ class Runtime:
335
+ """Tokio runtime instance. Usually not needed, as library global runtime is used by default."""
336
+
337
+ def __init__(self) -> None:
338
+ """Create a tokio runtime instance. This is an advanced feature."""
339
+
340
+ async def close(self) -> None:
341
+ """Shutdown runtime resources. Clients using this runtime won't work anymore after closing."""
@@ -0,0 +1,54 @@
1
+ """Types for pyreqwest client module."""
2
+
3
+ from collections.abc import Awaitable, Callable
4
+ from typing import Any, Literal, Protocol
5
+
6
+ from pyreqwest.http import HeaderMap
7
+ from pyreqwest.response import ResponseBodyReader, SyncResponseBodyReader
8
+
9
+
10
+ class JsonDumpsContext(Protocol):
11
+ """Data for json serializing."""
12
+
13
+ @property
14
+ def data(self) -> Any:
15
+ """The data to be serialized to JSON."""
16
+
17
+
18
+ class JsonLoadsContext(Protocol):
19
+ """Data for json deserializing."""
20
+
21
+ @property
22
+ def body_reader(self) -> ResponseBodyReader:
23
+ """The body reader to read the JSON data from."""
24
+
25
+ @property
26
+ def headers(self) -> HeaderMap:
27
+ """The response headers."""
28
+
29
+ @property
30
+ def extensions(self) -> dict[str, Any]:
31
+ """The extensions associated with the request."""
32
+
33
+
34
+ class SyncJsonLoadsContext(Protocol):
35
+ """Data for sync json deserializing."""
36
+
37
+ @property
38
+ def body_reader(self) -> SyncResponseBodyReader:
39
+ """The body reader to read the JSON data from."""
40
+
41
+ @property
42
+ def headers(self) -> HeaderMap:
43
+ """The response headers."""
44
+
45
+ @property
46
+ def extensions(self) -> dict[str, Any]:
47
+ """The extensions associated with the request."""
48
+
49
+
50
+ JsonDumps = Callable[[JsonDumpsContext], bytes | bytearray | memoryview]
51
+ JsonLoads = Callable[[JsonLoadsContext], Awaitable[Any]]
52
+ SyncJsonLoads = Callable[[SyncJsonLoadsContext], Any]
53
+
54
+ TlsVersion = Literal["TLSv1.0", "TLSv1.1", "TLSv1.2", "TLSv1.3"]
@@ -0,0 +1,5 @@
1
+ """Cookie related classes."""
2
+
3
+ from pyreqwest._pyreqwest.cookie import Cookie, CookieStore
4
+
5
+ __all__ = ["Cookie", "CookieStore"]