Skip to content
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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ permissions:
contents: write
packages: write

env:
MATURIN_VERSION: ${{ vars.MATURIN_VERSION }}

jobs:
style:
name: style
Expand Down Expand Up @@ -220,7 +223,7 @@ jobs:
with:
maturin-version: ${{ env.MATURIN_VERSION }}
target: ${{ matrix.platform.target }}
args: --release --out dist ${{ matrix.build_type.maturin_args }} --features ${{ matrix.platform.allocator || '' }}
args: --release --out dist ${{ matrix.platform.target != 'aarch64' && matrix.build_type.maturin_args || '' }} --features ${{ matrix.platform.allocator || '' }}
sccache: "false"
- name: Upload wheels
uses: actions/upload-artifact@v7
Expand Down
6 changes: 6 additions & 0 deletions python/wreq/http1.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ def __init__(self, **kwargs: Unpack[Params]) -> None:
Crate a new Http1Options instance.
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...
42 changes: 42 additions & 0 deletions python/wreq/http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ def __init__(self, src: int) -> None:
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...


@final
class StreamDependency:
Expand All @@ -149,6 +155,12 @@ def __init__(
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...


@final
class Priority:
Expand All @@ -172,6 +184,12 @@ def __init__(self, stream_id: StreamId, dependency: StreamDependency) -> None:
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...


@final
class Priorities:
Expand All @@ -191,6 +209,12 @@ def __init__(self, *priority: Priority) -> None:
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...


@final
class PseudoOrder:
Expand All @@ -209,6 +233,12 @@ def __init__(self, *pseudo_id: PseudoId) -> None:
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...


@final
class SettingsOrder:
Expand All @@ -228,6 +258,12 @@ def __init__(self, *setting_id: SettingId) -> None:
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...


class Params(TypedDict):
"""
Expand Down Expand Up @@ -359,3 +395,9 @@ def __init__(self, **kwargs: Unpack[Params]) -> None:
Create a new Http2Options instance.
"""
...

def __str__(self) -> str:
"""
Return a string representation of the type.
"""
...
7 changes: 1 addition & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod param;
mod query;

use std::{
fmt,
net::{IpAddr, Ipv4Addr, Ipv6Addr},
sync::Arc,
time::Duration,
Expand Down Expand Up @@ -55,11 +54,7 @@ impl SocketAddr {
}
}

impl fmt::Display for SocketAddr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
define_display!(SocketAddr);

/// A builder for `Client`.
#[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion src/client/resp/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Response {
.extensions()
.get::<wreq::redirect::History>()
.map_or_else(Vec::new, |history| {
history.into_iter().cloned().map(History::from).collect()
history.into_iter().cloned().map(History).collect()
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/resp/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl WebSocket {
pub async fn new(response: WebSocketResponse) -> wreq::Result<WebSocket> {
let (version, status, remote_addr, local_addr, headers) = (
Version::from_ffi(response.version()),
StatusCode::from(response.status()),
StatusCode(response.status()),
response.remote_addr().map(SocketAddr),
response.local_addr().map(SocketAddr),
HeaderMap(response.headers().clone()),
Expand Down
9 changes: 2 additions & 7 deletions src/client/resp/ws/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//!
//! The `Message` type is used for sending and receiving WebSocket messages in a unified way.

use std::fmt::{self, Debug};
use std::fmt::Debug;

use bytes::Bytes;
use pyo3::{
Expand Down Expand Up @@ -173,9 +173,4 @@ impl Message {
}
}

impl fmt::Display for Message {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
define_display!(Message);
8 changes: 2 additions & 6 deletions src/cookie.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt, sync::Arc, time::SystemTime};
use std::{sync::Arc, time::SystemTime};

use bytes::Bytes;
use cookie::{Cookie as RawCookie, Expiration, ParseError, time::Duration};
Expand Down Expand Up @@ -181,11 +181,7 @@ impl Cookie {
}
}

impl fmt::Display for Cookie {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
define_display!(Cookie);

// ===== impl Cookies =====

Expand Down
14 changes: 2 additions & 12 deletions src/header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt;

use bytes::Bytes;
use pyo3::{
prelude::*,
Expand Down Expand Up @@ -234,11 +232,7 @@ impl HeaderMap {
}
}

impl fmt::Display for HeaderMap {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
define_display!(HeaderMap);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::header::HeaderMap does not implement Display, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(HeaderMap);
define_display!(HeaderMap, debug);


impl FromPyObject<'_, '_> for HeaderMap {
type Error = PyErr;
Expand Down Expand Up @@ -347,11 +341,7 @@ impl OrigHeaderMap {
}
}

impl fmt::Display for OrigHeaderMap {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
define_display!(OrigHeaderMap);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::header::OrigHeaderMap does not implement Display, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(OrigHeaderMap);
define_display!(OrigHeaderMap, debug);


impl FromPyObject<'_, '_> for OrigHeaderMap {
type Error = PyErr;
Expand Down
14 changes: 1 addition & 13 deletions src/http.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt;

use pyo3::{class::basic::CompareOp, prelude::*};

define_enum!(
Expand Down Expand Up @@ -88,14 +86,4 @@ impl StatusCode {
}
}

impl From<wreq::StatusCode> for StatusCode {
fn from(status: wreq::StatusCode) -> Self {
Self(status)
}
}

impl fmt::Display for StatusCode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
define_display!(StatusCode);
4 changes: 3 additions & 1 deletion src/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct Builder {
/// These options allow you to customize the behavior of HTTP/1 connections,
/// such as enabling support for HTTP/0.9 responses, header case preservation, etc.
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct Http1Options(pub wreq::http1::Http1Options);

// ===== impl Builder =====
Expand Down Expand Up @@ -106,3 +106,5 @@ impl Http1Options {
})
}
}

define_display!(Http1Options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http1::Http1Options likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(Http1Options);
define_display!(Http1Options, debug);

30 changes: 22 additions & 8 deletions src/http2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::Duration;
use std::{fmt::Debug, time::Duration};

use pyo3::prelude::*;

Expand Down Expand Up @@ -50,7 +50,7 @@ define_enum!(
///
/// [Section 5.1.1]: https://tools.ietf.org/html/rfc7540#section-5.1.1
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct StreamId(wreq::http2::StreamId);

/// Represents a stream dependency in HTTP/2 priority frames.
Expand All @@ -66,15 +66,15 @@ pub struct StreamId(wreq::http2::StreamId);
/// can depend on another stream. This creates a priority hierarchy that helps
/// determine the relative order in which streams should be processed.
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct StreamDependency(wreq::http2::StreamDependency);

/// The PRIORITY frame (type=0x2) specifies the sender-advised priority
/// of a stream [Section 5.3]. It can be sent in any stream state,
/// including idle or closed streams.
/// [Section 5.3]: <https://tools.ietf.org/html/rfc7540#section-5.3>
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct Priority(wreq::http2::Priority);

/// A collection of HTTP/2 PRIORITY frames.
Expand All @@ -85,7 +85,7 @@ pub struct Priority(wreq::http2::Priority);
/// sending multiple PRIORITY frames at once during connection setup or
/// stream reprioritization.
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct Priorities(wreq::http2::Priorities);

/// Represents the order of HTTP/2 pseudo-header fields in a header block.
Expand All @@ -95,7 +95,7 @@ pub struct Priorities(wreq::http2::Priorities);
/// significant according to the HTTP/2 specification, and this type ensures that the correct order
/// is preserved and that no duplicates are present.
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct PseudoOrder(wreq::http2::PseudoOrder);

/// Represents the order of settings in a SETTINGS frame.
Expand All @@ -105,7 +105,7 @@ pub struct PseudoOrder(wreq::http2::PseudoOrder);
/// or interoperability. `SettingsOrder` ensures that the specified order is preserved and that no
/// duplicate settings are present.
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct SettingsOrder(wreq::http2::SettingsOrder);

/// A builder for [`Http2Options`].
Expand Down Expand Up @@ -183,7 +183,7 @@ struct Builder {
/// This struct defines various parameters to fine-tune the behavior of an HTTP/2 connection,
/// including stream management, window sizes, frame limits, and header config.
#[derive(Clone)]
#[pyclass(frozen, from_py_object)]
#[pyclass(frozen, str, from_py_object)]
pub struct Http2Options(pub wreq::http2::Http2Options);

// ===== impl StreamId =====
Expand All @@ -206,6 +206,8 @@ impl StreamId {
}
}

define_display!(StreamId);

// ===== impl StreamDependency =====

#[pymethods]
Expand All @@ -222,6 +224,8 @@ impl StreamDependency {
}
}

define_display!(StreamDependency);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http2::StreamDependency likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(StreamDependency);
define_display!(StreamDependency, debug);


// ===== impl Priority =====

#[pymethods]
Expand All @@ -234,6 +238,8 @@ impl Priority {
}
}

define_display!(Priority);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http2::Priority likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(Priority);
define_display!(Priority, debug);


// ===== impl Priorities =====

#[pymethods]
Expand All @@ -250,6 +256,8 @@ impl Priorities {
}
}

define_display!(Priorities);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http2::Priorities likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(Priorities);
define_display!(Priorities, debug);


// ===== impl PseudoOrder =====

#[pymethods]
Expand All @@ -266,6 +274,8 @@ impl PseudoOrder {
}
}

define_display!(PseudoOrder);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http2::PseudoOrder likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(PseudoOrder);
define_display!(PseudoOrder, debug);


// ===== impl SettingsOrder =====

#[pymethods]
Expand All @@ -282,6 +292,8 @@ impl SettingsOrder {
}
}

define_display!(SettingsOrder);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http2::SettingsOrder likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(SettingsOrder);
define_display!(SettingsOrder, debug);


// ===== impl Builder =====

impl FromPyObject<'_, '_> for Builder {
Expand Down Expand Up @@ -449,3 +461,5 @@ impl Http2Options {
})
}
}

define_display!(Http2Options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since wreq::http2::Http2Options likely only implements Debug, you should use the debug variant of the improved define_display! macro.

Suggested change
define_display!(Http2Options);
define_display!(Http2Options, debug);

Loading
Loading