Skip to main content

eggfetch_python/
lib.rs

1//! Python bindings for eggfetch.
2
3use pyo3::prelude::*;
4
5mod async_client;
6mod auth;
7mod client;
8mod conversion;
9mod cookies;
10mod errors;
11mod extensions;
12mod headers;
13mod limits;
14mod multipart;
15mod network_stream;
16mod proxy;
17mod request_preparation;
18mod response;
19mod retry;
20mod streaming;
21mod timeout;
22mod tls;
23mod trace_bridge;
24
25use async_client::PyAsyncClient;
26use auth::{PyBasicAuth, PyBearerAuth, PyNoAuth};
27use client::PyClient;
28use cookies::PyCookies;
29use errors::map_err;
30use headers::PyHeaders;
31use limits::PyLimits;
32use multipart::PyFile;
33use response::{
34    PyResponse, PyResponseBytesIterator, PyResponseLinesIterator, PyResponseTextIterator,
35};
36use retry::PyRetry;
37use streaming::{
38    PyAsyncBytesIterator, PyAsyncLinesIterator, PyAsyncRawBytesIterator, PyAsyncTextIterator,
39    PyBytesChunkIterator, PyLinesChunkIterator, PyRawBytesChunkIterator, PyStreamingResponse,
40    PyTextChunkIterator,
41};
42use timeout::PyTimeout;
43
44/// Send an HTTP request using a short-lived client.
45///
46/// Args:
47///     method: HTTP method string.
48///     url: Target URL.
49///     headers: Request headers dict or sequence of pairs (optional).
50///     params: Query parameters dict or sequence of pairs (optional).
51///     content: Raw request body as bytes (optional).
52///     data: Form data as dict or sequence of pairs (optional).
53///     json: JSON-serializable object (optional).
54///     files: File uploads as mapping or sequence of pairs (optional).
55///     timeout: Request timeout in seconds, or Timeout object (optional).
56///     cookies: Initial cookies as dict of name=value pairs (optional).
57///     auth: Authentication credentials (optional).
58///     `follow_redirects`: Whether to follow redirects (default False).
59///     `max_redirects`: Maximum redirects to follow (default 20).
60///
61/// Note: one-shot helpers (`request`/`get`/`post`/...) accept no
62/// `extensions` argument (resolved-target pinning, SNI override, and
63/// trace observers are `Client`/`AsyncClient`-level only) and accept
64/// per-request `limits`, which `Client.request`/`stream` do not
65/// (client-level constructor only). This asymmetry is intentional:
66/// one-shots own their client, so per-request limits are free;
67/// persistent clients share a pool, so limits stay constructor-level.
68#[pyfunction]
69#[pyo3(signature = (method, url, *, headers=None, params=None, content=None, data=None, json=None, files=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
70#[allow(
71    clippy::too_many_arguments,
72    clippy::too_many_lines,
73    reason = "the parameters are the public one-shot keyword surface, and the body keeps the shared preparation boundary, the short-lived runtime, and the dispatch in one flow"
74)]
75fn request<'py>(
76    py: Python<'py>,
77    method: &str,
78    url: &str,
79    headers: Option<&Bound<'py, PyAny>>,
80    params: Option<&Bound<'py, PyAny>>,
81    content: Option<&Bound<'py, PyAny>>,
82    data: Option<&Bound<'py, PyAny>>,
83    json: Option<&Bound<'py, PyAny>>,
84    files: Option<&Bound<'py, PyAny>>,
85    timeout: Option<&Bound<'py, PyAny>>,
86    cookies: Option<&Bound<'py, PyAny>>,
87    auth: Option<&Bound<'py, PyAny>>,
88    follow_redirects: Option<bool>,
89    max_redirects: Option<usize>,
90    decompress: Option<bool>,
91    proxy: Option<&Bound<'py, PyAny>>,
92    verify: Option<&Bound<'py, PyAny>>,
93    cert: Option<&Bound<'py, PyAny>>,
94    retries: Option<&Bound<'py, PyAny>>,
95    limits: Option<&Bound<'py, PyAny>>,
96) -> PyResult<Bound<'py, PyAny>> {
97    let prepared = request_preparation::prepare_request(
98        py,
99        method,
100        url,
101        headers,
102        params,
103        content,
104        data,
105        json,
106        files,
107        timeout,
108        cookies,
109        auth,
110        follow_redirects,
111        max_redirects,
112        proxy,
113        retries,
114        None,
115        false,
116    )?;
117
118    let runtime = py
119        .detach(tokio::runtime::Runtime::new)
120        .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
121
122    let tls_config = tls::build_tls_config(verify, cert, None)?;
123
124    let mut client_builder = eggfetch_core::Client::builder()
125        .redirect_policy(eggfetch_core::redirect::RedirectPolicy::new(
126            follow_redirects.unwrap_or(false),
127            max_redirects.unwrap_or(20),
128        ))
129        .tls_config(tls_config);
130
131    if let Some(l) = limits {
132        let py_limits: PyLimits = l.extract()?;
133        client_builder = client_builder.limits(py_limits.inner);
134    }
135
136    let client = client_builder.build();
137    let dispatch = request_preparation::prepare_core_dispatch(
138        &client,
139        prepared,
140        request_preparation::RequestDispatchDefaults {
141            redirect_policy: eggfetch_core::redirect::RedirectPolicy::new(
142                follow_redirects.unwrap_or(false),
143                max_redirects.unwrap_or(20),
144            ),
145            decompress,
146            // The one-shot helpers are the native surface and own no
147            // environment configuration, so they always use the native
148            // proxy semantics.
149            proxy_env_semantics: crate::proxy::ProxyEnvSemantics::Native,
150        },
151    )?;
152    let builder = dispatch.builder;
153
154    let result = py.detach(|| {
155        runtime.block_on(async {
156            let mut response = Box::pin(builder.send()).await.map_err(map_err)?;
157            let content = response.bytes().await.map_err(map_err)?;
158            Ok::<_, PyErr>((response, content))
159        })
160    });
161
162    let (mut response, content) = result?;
163    // The top-level short-lived helpers do not own a persistent runtime,
164    // so the network stream (if any) gets no explicit handle or lease.
165    let py_response =
166        PyResponse::from_core_response_with_body(&mut response, content, None, None, false)?;
167    Ok(Py::new(py, py_response)?.into_bound(py).into_any())
168}
169
170/// Send a GET request using a short-lived client.
171#[pyfunction]
172#[pyo3(signature = (url, *, headers=None, params=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
173#[allow(
174    clippy::too_many_arguments,
175    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
176)]
177fn get<'py>(
178    py: Python<'py>,
179    url: &str,
180    headers: Option<&Bound<'py, PyAny>>,
181    params: Option<&Bound<'py, PyAny>>,
182    timeout: Option<&Bound<'py, PyAny>>,
183    cookies: Option<&Bound<'py, PyAny>>,
184    auth: Option<&Bound<'py, PyAny>>,
185    follow_redirects: Option<bool>,
186    max_redirects: Option<usize>,
187    decompress: Option<bool>,
188    proxy: Option<&Bound<'py, PyAny>>,
189    verify: Option<&Bound<'py, PyAny>>,
190    cert: Option<&Bound<'py, PyAny>>,
191    retries: Option<&Bound<'py, PyAny>>,
192    limits: Option<&Bound<'py, PyAny>>,
193) -> PyResult<Bound<'py, PyAny>> {
194    request(
195        py,
196        "GET",
197        url,
198        headers,
199        params,
200        None,
201        None,
202        None,
203        None,
204        timeout,
205        cookies,
206        auth,
207        follow_redirects,
208        max_redirects,
209        decompress,
210        proxy,
211        verify,
212        cert,
213        retries,
214        limits,
215    )
216}
217
218/// Send a POST request using a short-lived client.
219#[pyfunction]
220#[pyo3(signature = (url, *, headers=None, params=None, content=None, data=None, json=None, files=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
221#[allow(
222    clippy::too_many_arguments,
223    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
224)]
225fn post<'py>(
226    py: Python<'py>,
227    url: &str,
228    headers: Option<&Bound<'py, PyAny>>,
229    params: Option<&Bound<'py, PyAny>>,
230    content: Option<&Bound<'py, PyAny>>,
231    data: Option<&Bound<'py, PyAny>>,
232    json: Option<&Bound<'py, PyAny>>,
233    files: Option<&Bound<'py, PyAny>>,
234    timeout: Option<&Bound<'py, PyAny>>,
235    cookies: Option<&Bound<'py, PyAny>>,
236    auth: Option<&Bound<'py, PyAny>>,
237    follow_redirects: Option<bool>,
238    max_redirects: Option<usize>,
239    decompress: Option<bool>,
240    proxy: Option<&Bound<'py, PyAny>>,
241    verify: Option<&Bound<'py, PyAny>>,
242    cert: Option<&Bound<'py, PyAny>>,
243    retries: Option<&Bound<'py, PyAny>>,
244    limits: Option<&Bound<'py, PyAny>>,
245) -> PyResult<Bound<'py, PyAny>> {
246    request(
247        py,
248        "POST",
249        url,
250        headers,
251        params,
252        content,
253        data,
254        json,
255        files,
256        timeout,
257        cookies,
258        auth,
259        follow_redirects,
260        max_redirects,
261        decompress,
262        proxy,
263        verify,
264        cert,
265        retries,
266        limits,
267    )
268}
269
270/// Send a PUT request using a short-lived client.
271#[pyfunction]
272#[pyo3(signature = (url, *, headers=None, params=None, content=None, data=None, json=None, files=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
273#[allow(
274    clippy::too_many_arguments,
275    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
276)]
277fn put<'py>(
278    py: Python<'py>,
279    url: &str,
280    headers: Option<&Bound<'py, PyAny>>,
281    params: Option<&Bound<'py, PyAny>>,
282    content: Option<&Bound<'py, PyAny>>,
283    data: Option<&Bound<'py, PyAny>>,
284    json: Option<&Bound<'py, PyAny>>,
285    files: Option<&Bound<'py, PyAny>>,
286    timeout: Option<&Bound<'py, PyAny>>,
287    cookies: Option<&Bound<'py, PyAny>>,
288    auth: Option<&Bound<'py, PyAny>>,
289    follow_redirects: Option<bool>,
290    max_redirects: Option<usize>,
291    decompress: Option<bool>,
292    proxy: Option<&Bound<'py, PyAny>>,
293    verify: Option<&Bound<'py, PyAny>>,
294    cert: Option<&Bound<'py, PyAny>>,
295    retries: Option<&Bound<'py, PyAny>>,
296    limits: Option<&Bound<'py, PyAny>>,
297) -> PyResult<Bound<'py, PyAny>> {
298    request(
299        py,
300        "PUT",
301        url,
302        headers,
303        params,
304        content,
305        data,
306        json,
307        files,
308        timeout,
309        cookies,
310        auth,
311        follow_redirects,
312        max_redirects,
313        decompress,
314        proxy,
315        verify,
316        cert,
317        retries,
318        limits,
319    )
320}
321
322/// Send a PATCH request using a short-lived client.
323#[pyfunction]
324#[pyo3(signature = (url, *, headers=None, params=None, content=None, data=None, json=None, files=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
325#[allow(
326    clippy::too_many_arguments,
327    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
328)]
329fn patch<'py>(
330    py: Python<'py>,
331    url: &str,
332    headers: Option<&Bound<'py, PyAny>>,
333    params: Option<&Bound<'py, PyAny>>,
334    content: Option<&Bound<'py, PyAny>>,
335    data: Option<&Bound<'py, PyAny>>,
336    json: Option<&Bound<'py, PyAny>>,
337    files: Option<&Bound<'py, PyAny>>,
338    timeout: Option<&Bound<'py, PyAny>>,
339    cookies: Option<&Bound<'py, PyAny>>,
340    auth: Option<&Bound<'py, PyAny>>,
341    follow_redirects: Option<bool>,
342    max_redirects: Option<usize>,
343    decompress: Option<bool>,
344    proxy: Option<&Bound<'py, PyAny>>,
345    verify: Option<&Bound<'py, PyAny>>,
346    cert: Option<&Bound<'py, PyAny>>,
347    retries: Option<&Bound<'py, PyAny>>,
348    limits: Option<&Bound<'py, PyAny>>,
349) -> PyResult<Bound<'py, PyAny>> {
350    request(
351        py,
352        "PATCH",
353        url,
354        headers,
355        params,
356        content,
357        data,
358        json,
359        files,
360        timeout,
361        cookies,
362        auth,
363        follow_redirects,
364        max_redirects,
365        decompress,
366        proxy,
367        verify,
368        cert,
369        retries,
370        limits,
371    )
372}
373
374/// Send a DELETE request using a short-lived client.
375#[pyfunction]
376#[pyo3(signature = (url, *, headers=None, params=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
377#[allow(
378    clippy::too_many_arguments,
379    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
380)]
381fn delete<'py>(
382    py: Python<'py>,
383    url: &str,
384    headers: Option<&Bound<'py, PyAny>>,
385    params: Option<&Bound<'py, PyAny>>,
386    timeout: Option<&Bound<'py, PyAny>>,
387    cookies: Option<&Bound<'py, PyAny>>,
388    auth: Option<&Bound<'py, PyAny>>,
389    follow_redirects: Option<bool>,
390    max_redirects: Option<usize>,
391    decompress: Option<bool>,
392    proxy: Option<&Bound<'py, PyAny>>,
393    verify: Option<&Bound<'py, PyAny>>,
394    cert: Option<&Bound<'py, PyAny>>,
395    retries: Option<&Bound<'py, PyAny>>,
396    limits: Option<&Bound<'py, PyAny>>,
397) -> PyResult<Bound<'py, PyAny>> {
398    request(
399        py,
400        "DELETE",
401        url,
402        headers,
403        params,
404        None,
405        None,
406        None,
407        None,
408        timeout,
409        cookies,
410        auth,
411        follow_redirects,
412        max_redirects,
413        decompress,
414        proxy,
415        verify,
416        cert,
417        retries,
418        limits,
419    )
420}
421
422/// Send a HEAD request using a short-lived client.
423#[pyfunction]
424#[pyo3(signature = (url, *, headers=None, params=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
425#[allow(
426    clippy::too_many_arguments,
427    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
428)]
429fn head<'py>(
430    py: Python<'py>,
431    url: &str,
432    headers: Option<&Bound<'py, PyAny>>,
433    params: Option<&Bound<'py, PyAny>>,
434    timeout: Option<&Bound<'py, PyAny>>,
435    cookies: Option<&Bound<'py, PyAny>>,
436    auth: Option<&Bound<'py, PyAny>>,
437    follow_redirects: Option<bool>,
438    max_redirects: Option<usize>,
439    decompress: Option<bool>,
440    proxy: Option<&Bound<'py, PyAny>>,
441    verify: Option<&Bound<'py, PyAny>>,
442    cert: Option<&Bound<'py, PyAny>>,
443    retries: Option<&Bound<'py, PyAny>>,
444    limits: Option<&Bound<'py, PyAny>>,
445) -> PyResult<Bound<'py, PyAny>> {
446    request(
447        py,
448        "HEAD",
449        url,
450        headers,
451        params,
452        None,
453        None,
454        None,
455        None,
456        timeout,
457        cookies,
458        auth,
459        follow_redirects,
460        max_redirects,
461        decompress,
462        proxy,
463        verify,
464        cert,
465        retries,
466        limits,
467    )
468}
469
470/// Send an OPTIONS request using a short-lived client.
471#[pyfunction]
472#[pyo3(signature = (url, *, headers=None, params=None, timeout=None, cookies=None, auth=None, follow_redirects=None, max_redirects=None, decompress=None, proxy=None, verify=None, cert=None, retries=None, limits=None))]
473#[allow(
474    clippy::too_many_arguments,
475    reason = "the parameter list is the public one-shot keyword surface, forwarded verbatim to `request`"
476)]
477fn options<'py>(
478    py: Python<'py>,
479    url: &str,
480    headers: Option<&Bound<'py, PyAny>>,
481    params: Option<&Bound<'py, PyAny>>,
482    timeout: Option<&Bound<'py, PyAny>>,
483    cookies: Option<&Bound<'py, PyAny>>,
484    auth: Option<&Bound<'py, PyAny>>,
485    follow_redirects: Option<bool>,
486    max_redirects: Option<usize>,
487    decompress: Option<bool>,
488    proxy: Option<&Bound<'py, PyAny>>,
489    verify: Option<&Bound<'py, PyAny>>,
490    cert: Option<&Bound<'py, PyAny>>,
491    retries: Option<&Bound<'py, PyAny>>,
492    limits: Option<&Bound<'py, PyAny>>,
493) -> PyResult<Bound<'py, PyAny>> {
494    request(
495        py,
496        "OPTIONS",
497        url,
498        headers,
499        params,
500        None,
501        None,
502        None,
503        None,
504        timeout,
505        cookies,
506        auth,
507        follow_redirects,
508        max_redirects,
509        decompress,
510        proxy,
511        verify,
512        cert,
513        retries,
514        limits,
515    )
516}
517
518/// Register all exception types on the module.
519fn register_exceptions(m: &Bound<'_, PyModule>) -> PyResult<()> {
520    m.add("EggfetchError", m.py().get_type::<errors::EggfetchError>())?;
521    m.add("RequestError", m.py().get_type::<errors::RequestError>())?;
522    m.add("InvalidUrl", m.py().get_type::<errors::InvalidUrl>())?;
523    m.add(
524        "TimeoutException",
525        m.py().get_type::<errors::TimeoutException>(),
526    )?;
527    m.add("PoolTimeout", m.py().get_type::<errors::PoolTimeout>())?;
528    m.add(
529        "ConnectTimeout",
530        m.py().get_type::<errors::ConnectTimeout>(),
531    )?;
532    m.add("ReadTimeout", m.py().get_type::<errors::ReadTimeout>())?;
533    m.add("WriteTimeout", m.py().get_type::<errors::WriteTimeout>())?;
534    m.add("NetworkError", m.py().get_type::<errors::NetworkError>())?;
535    m.add("ProtocolError", m.py().get_type::<errors::ProtocolError>())?;
536    m.add("BodyError", m.py().get_type::<errors::BodyError>())?;
537    m.add(
538        "HTTPStatusError",
539        m.py().get_type::<errors::HTTPStatusError>(),
540    )?;
541    m.add(
542        "UnsupportedKwarg",
543        m.py().get_type::<errors::UnsupportedKwarg>(),
544    )?;
545    m.add(
546        "TooManyRedirects",
547        m.py().get_type::<errors::TooManyRedirects>(),
548    )?;
549    m.add(
550        "StreamConsumed",
551        m.py().get_type::<errors::StreamConsumed>(),
552    )?;
553    m.add("StreamClosed", m.py().get_type::<errors::StreamClosed>())?;
554    m.add(
555        "ResponseNotRead",
556        m.py().get_type::<errors::ResponseNotRead>(),
557    )?;
558    m.add(
559        "DecompressionError",
560        m.py().get_type::<errors::DecompressionError>(),
561    )?;
562    m.add(
563        "UnsupportedContentEncoding",
564        m.py().get_type::<errors::UnsupportedContentEncoding>(),
565    )?;
566    m.add("ProxyError", m.py().get_type::<errors::ProxyError>())?;
567    m.add(
568        "ProxyConnectError",
569        m.py().get_type::<errors::ProxyConnectError>(),
570    )?;
571    m.add(
572        "ProxyAuthError",
573        m.py().get_type::<errors::ProxyAuthError>(),
574    )?;
575    m.add(
576        "BodyNotReplayableForRetry",
577        m.py().get_type::<errors::BodyNotReplayableForRetry>(),
578    )?;
579    m.add(
580        "RetryBudgetExhausted",
581        m.py().get_type::<errors::RetryBudgetExhausted>(),
582    )?;
583    m.add(
584        "RetryNotConfigured",
585        m.py().get_type::<errors::RetryNotConfigured>(),
586    )?;
587    m.add("Http2Error", m.py().get_type::<errors::Http2Error>())?;
588    m.add("Http2GoAway", m.py().get_type::<errors::Http2GoAway>())?;
589    m.add(
590        "Http2StreamReset",
591        m.py().get_type::<errors::Http2StreamReset>(),
592    )?;
593    m.add(
594        "Http2FlowControlError",
595        m.py().get_type::<errors::Http2FlowControlError>(),
596    )?;
597    m.add("H3Error", m.py().get_type::<errors::H3Error>())?;
598    m.add(
599        "H3ConnectError",
600        m.py().get_type::<errors::H3ConnectError>(),
601    )?;
602    m.add(
603        "H3ProtocolError",
604        m.py().get_type::<errors::H3ProtocolError>(),
605    )?;
606    Ok(())
607}
608
609/// eggfetch - Python bindings for eggfetch.
610#[pymodule]
611fn _native(m: &Bound<'_, PyModule>) -> PyResult<()> {
612    m.add("__version__", env!("CARGO_PKG_VERSION"))?;
613
614    m.add_class::<PyAsyncClient>()?;
615    m.add_class::<PyClient>()?;
616    m.add_class::<cookies::PyCookie>()?;
617    m.add_class::<PyCookies>()?;
618    m.add_class::<PyHeaders>()?;
619    m.add_class::<PyResponse>()?;
620    m.add_class::<PyResponseBytesIterator>()?;
621    m.add_class::<PyResponseTextIterator>()?;
622    m.add_class::<PyResponseLinesIterator>()?;
623    m.add_class::<PyStreamingResponse>()?;
624    m.add_class::<PyBytesChunkIterator>()?;
625    m.add_class::<PyTextChunkIterator>()?;
626    m.add_class::<PyLinesChunkIterator>()?;
627    m.add_class::<PyRawBytesChunkIterator>()?;
628    m.add_class::<PyAsyncBytesIterator>()?;
629    m.add_class::<PyAsyncTextIterator>()?;
630    m.add_class::<PyAsyncLinesIterator>()?;
631    m.add_class::<PyAsyncRawBytesIterator>()?;
632    m.add_class::<PyTimeout>()?;
633    m.add_class::<PyBasicAuth>()?;
634    m.add_class::<PyBearerAuth>()?;
635    m.add_class::<PyNoAuth>()?;
636    m.add_class::<PyFile>()?;
637    m.add_class::<PyRetry>()?;
638    m.add_class::<PyLimits>()?;
639    m.add_class::<network_stream::PyNetworkStream>()?;
640    m.add_class::<network_stream::PyAsyncNetworkStream>()?;
641
642    // Create the NOAUTH singleton instance.
643    let noauth_obj = Py::new(m.py(), PyNoAuth)?;
644    m.add("NOAUTH", noauth_obj.bind(m.py()).clone())?;
645
646    register_exceptions(m)?;
647
648    m.add_function(wrap_pyfunction!(request, m)?)?;
649    m.add_function(wrap_pyfunction!(get, m)?)?;
650    m.add_function(wrap_pyfunction!(post, m)?)?;
651    m.add_function(wrap_pyfunction!(put, m)?)?;
652    m.add_function(wrap_pyfunction!(patch, m)?)?;
653    m.add_function(wrap_pyfunction!(delete, m)?)?;
654    m.add_function(wrap_pyfunction!(head, m)?)?;
655    m.add_function(wrap_pyfunction!(options, m)?)?;
656
657    // PyO3 automatically builds a module __all__ from every add/add_class
658    // call. The pure-Python eggfetch package owns the supported export
659    // contract, so do not expose a second contract from this private module.
660    m.delattr("__all__")?;
661
662    Ok(())
663}