8000 feat: Python bindings now support subclass inheritance for classes by 0x676e67 · Pull Request #209 · 0x676e67/rnet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Python bindings now support subclass inheritance for classes #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rnet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ class BlockingClient:

class BlockingResponse:
r"""
A bloking response from a request.
A blocking response from a request.
"""

url: str
Expand Down
4 changes: 2 additions & 2 deletions src/async_impl/response/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{ops::Deref, pin::Pin, sync::Arc};
use tokio::sync::Mutex;

/// A response from a request.
#[pyclass]
#[pyclass(subclass)]
pub struct Response {
url: Url,
version: Version,
Expand Down Expand Up @@ -231,7 +231,7 @@ type InnerStreamer = Pin<Box<dyn Stream<Item = rquest::Result<bytes::Bytes>> + S
/// Used to stream response content.
/// Implemented in the `stream` method of the `Response` class.
/// Can be used in an asynchronous for loop in Python.
#[pyclass]
#[pyclass(subclass)]
#[derive(Clone)]
pub struct Streamer(Arc<Mutex<Option<InnerStreamer>>>);

Expand Down
2 changes: 1 addition & 1 deletion src/async_impl/response/ws/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
};

/// A WebSocket message.
#[pyclass]
#[pyclass(subclass)]
#[derive(Clone)]
pub struct Message(pub rquest::Message);

Expand Down
2 changes: 1 addition & 1 deletion src/async_impl/response/ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Sender = Arc<Mutex<Option<SplitSink<rquest::WebSocket, rquest::Message>>>>;
type Receiver = Arc<Mutex<Option<SplitStream<rquest::WebSocket>>>>;

/// A WebSocket response.
#[pyclass]
#[pyclass(subclass)]
pub struct WebSocket {
version: Version,
status_code: StatusCode,
Expand Down
6 changes: 3 additions & 3 deletions src/blocking/response/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::{
};
use pyo3::prelude::*;

/// A bloking response from a request.
#[pyclass]
/// A blocking response from a request.
#[pyclass(subclass)]
pub struct BlockingResponse(async_impl::Response);

impl From<async_impl::Response> for BlockingResponse {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl BlockingResponse {
/// Used for streaming response content.
/// Employed in the `stream` method of the `Response` class.
/// Utilized in an asynchronous for loop in Python.
#[pyclass]
#[pyclass(subclass)]
pub struct BlockingStreamer(async_impl::Streamer);

#[pymethods]
Expand Down
2 changes: 1 addition & 1 deletion src/blocking/response/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
use pyo3::{prelude::*, pybacked::PyBackedStr};

/// A blocking WebSocket response.
#[pyclass]
#[pyclass(subclass)]
pub struct BlockingWebSocket(async_impl::WebSocket);

impl From<async_impl::WebSocket> for BlockingWebSocket {
Expand Down
2 changes: 1 addition & 1 deletion src/typing/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rquest::header::{self, HeaderMap, HeaderValue};
use std::time::SystemTime;

/// A cookie.
#[pyclass]
#[pyclass(subclass)]
#[derive(Clone)]
pub struct Cookie(pub cookie::Cookie<'static>);

Expand Down
8 changes: 4 additions & 4 deletions src/typing/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use pyo3::{
use rquest::header::{self, HeaderName, HeaderValue};

/// A HTTP header map.
#[pyclass]
#[pyclass(subclass)]
pub struct HeaderMap(pub header::HeaderMap);

#[pymethods]
Expand Down Expand Up @@ -159,7 +159,7 @@ impl HeaderMap {
}

/// An iterator over the keys in a HeaderMap.
#[pyclass]
#[pyclass(subclass)]
pub struct HeaderMapKeysIter {
inner: Vec<HeaderName>,
}
Expand All @@ -180,7 +180,7 @@ impl HeaderMapKeysIter {
}

/// An iterator over the values in a HeaderMap.
#[pyclass]
#[pyclass(subclass)]
pub struct HeaderMapValuesIter {
inner: Vec<HeaderValue>,
}
Expand All @@ -200,7 +200,7 @@ impl HeaderMapValuesIter {
}

/// An iterator over the items in a HeaderMap.
#[pyclass]
#[pyclass(subclass)]
pub struct HeaderMapItemsIter {
inner: Vec<(HeaderName, HeaderValue)>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/typing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rquest_util::EmulationOption;
use serde::ser::{Serialize, SerializeSeq, Serializer};

/// A struct to represent the `ImpersonateOption` class.
#[pyclass]
#[pyclass(subclass)]
pub struct ImpersonateOption {
/// The browser version to impersonate.
impersonate: Impersonate,
Expand Down
2 changes: 1 addition & 1 deletion src/typing/multipart/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pyo3::{prelude::*, types::PyTuple};
use rquest::multipart::Form;

/// A multipart form for a request.
#[pyclass]
#[pyclass(subclass)]
pub struct Multipart(pub Option<Form>);

#[pymethods]
Expand Down
2 changes: 1 addition & 1 deletion src/typing/multipart/part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rquest::Body;
use std::path::PathBuf;

/// A part of a multipart form.
#[pyclass]
#[pyclass(subclass)]
pub struct Part {
pub name: Option<String>,
pub inner: Option<rquest::multipart::Part>,
Expand Down
2 changes: 1 addition & 1 deletion src/typing/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ macro_rules! proxy_method {

/// A proxy server for a request.
/// Supports HTTP, HTTPS, SOCKS4, SOCKS4a, SOCKS5, and SOCKS5h protocols.
#[pyclass]
#[pyclass(subclass)]
pub struct Proxy(pub rquest::Proxy);

proxy_method! {
473B Expand Down
Loading
0