Skip to content

Conversation

@wuqunfei
Copy link
Contributor

Summary

This release adds HTTPX-compatible transport protocol classes and improves client extensibility by enabling subclassing of the Client and AsyncClient classes. Version bumped to 1.0.5.

Key Changes

  • Version bump: Updated version from 1.0.4 to 1.0.5 in both Cargo.toml and pyproject.toml

  • Transport Protocol Stubs: Added two new @runtime_checkable Protocol classes for HTTPX compatibility:

    • BaseTransport: Protocol for synchronous HTTP transports with handle_request() and close() methods
    • AsyncBaseTransport: Protocol for asynchronous HTTP transports with handle_async_request() and aclose() methods
    • These enable type checking and isinstance() checks for custom transport implementations
  • Client Subclassing Support:

    • Added subclass attribute to #[pyclass] macro for both Client and AsyncClient in Rust
    • This allows users to extend these classes in Python for custom behavior
  • Timeout Property: Added timeout getter property to both Client and AsyncClient to expose the configured timeout

  • URL.raw_path Enhancement: Changed raw_path property to return Vec<u8> (bytes) instead of String for HTTPX compatibility, matching the expected behavior of HTTP client libraries

  • Type Imports: Added comprehensive type imports from typing module to support the new Protocol definitions

Implementation Details

The transport protocol classes are defined as Protocol stubs rather than concrete base classes, allowing for duck-typing while maintaining type safety. The @runtime_checkable decorator enables runtime type checking via isinstance() for custom transport implementations that follow the protocol interface.

https://claude.ai/code/session_012d1P2tyccgiracqGeVsC2V

- Make Client and AsyncClient subclassable via PyO3 subclass attribute
- Add timeout getter to Client and AsyncClient to expose configured timeout
- Change URL.raw_path to return bytes instead of str (HTTPX compatible)
- Add BaseTransport and AsyncBaseTransport Protocol stubs for type checking
- Bump version to 1.0.5

These changes address the compatibility issues identified in:
neuesql/openai-python#1

https://claude.ai/code/session_012d1P2tyccgiracqGeVsC2V
@wuqunfei wuqunfei merged commit b8aa562 into main Jan 27, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants