Add HTTPX transport protocol stubs and improve client extensibility #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This release adds HTTPX-compatible transport protocol classes and improves client extensibility by enabling subclassing of the
ClientandAsyncClientclasses. Version bumped to 1.0.5.Key Changes
Version bump: Updated version from 1.0.4 to 1.0.5 in both
Cargo.tomlandpyproject.tomlTransport Protocol Stubs: Added two new
@runtime_checkableProtocol classes for HTTPX compatibility:BaseTransport: Protocol for synchronous HTTP transports withhandle_request()andclose()methodsAsyncBaseTransport: Protocol for asynchronous HTTP transports withhandle_async_request()andaclose()methodsisinstance()checks for custom transport implementationsClient Subclassing Support:
subclassattribute to#[pyclass]macro for bothClientandAsyncClientin RustTimeout Property: Added
timeoutgetter property to bothClientandAsyncClientto expose the configured timeoutURL.raw_path Enhancement: Changed
raw_pathproperty to returnVec<u8>(bytes) instead ofStringfor HTTPX compatibility, matching the expected behavior of HTTP client librariesType Imports: Added comprehensive type imports from
typingmodule to support the new Protocol definitionsImplementation Details
The transport protocol classes are defined as
Protocolstubs rather than concrete base classes, allowing for duck-typing while maintaining type safety. The@runtime_checkabledecorator enables runtime type checking viaisinstance()for custom transport implementations that follow the protocol interface.https://claude.ai/code/session_012d1P2tyccgiracqGeVsC2V