Expose client option types #1977
-
The type hints for the An alternative solution to forwarding arguments would be for users to directly provide their own client instances, however I'd rather support forwarding arguments as I want to be able to set defaults for certain options and I do not know how well httpx plays with modifying options post I already have a PR lined up for this if it is deemed necessary: RobertCraigie@bd21754 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I'd prefer that we avoid this if possible. Something feels a bit odd about including types as part of our API, that I don't know how to express. (We include the byte stream cases because it's necessary to subclass them for some kinds of usage.) |
Beta Was this translation helpful? Give feedback.
-
Hey there, I came here with this exact issue.
@lovelydinosaur I will argue the exact opposite. The arguments to your public classes, in my case Concretely, I have a method where I want to pass through keyword arguments given to the method to the constructor of import ssl
from typing import Iterable, TypedDict
import httpx
class HTTPXAsyncHTTPTransportKeywordArguments(TypedDict, total=False):
"""Keyword arguments for the httpx.AsyncHTTPTransport constructor."""
verify: ssl.SSLContext | str | bool
cert: httpx._types.CertTypes | None
trust_env: bool
http1: bool
http2: bool
limits: httpx._config.Limits
proxy: httpx._types.ProxyTypes | None
uds: str | None
local_address: str | None
retries: int
socket_options: Iterable[httpx._transports.default.SOCKET_OPTION] | None and elsewhere I can then use that @classmethod
def create(
cls,
limiter: AbstractAsyncLimiter,
**kwargs: Unpack[HTTPXAsyncHTTPTransportKeywordArguments],
) -> AsyncRateLimitedTransport:
return cls(
limiter=limiter,
transport=httpx.AsyncHTTPTransport(**kwargs),
) |
Beta Was this translation helpful? Give feedback.
I'd prefer that we avoid this if possible.
Something feels a bit odd about including types as part of our API, that I don't know how to express. (We include the byte stream cases because it's necessary to subclass them for some kinds of usage.)