(
self,
*,
version: str,
base_url: str | URL,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.Client | None = None,
custom_headers: Mapping[str, str] | None = None,
custom_query: Mapping[str, object] | None = None,
middleware: Sequence[MiddlewareInput] | None = None,
_strict_response_validation: bool,
)
| 982 | webhook_key: str | None = None |
| 983 | |
| 984 | def __init__( |
| 985 | self, |
| 986 | *, |
| 987 | version: str, |
| 988 | base_url: str | URL, |
| 989 | max_retries: int = DEFAULT_MAX_RETRIES, |
| 990 | timeout: float | Timeout | None | NotGiven = not_given, |
| 991 | http_client: httpx.Client | None = None, |
| 992 | custom_headers: Mapping[str, str] | None = None, |
| 993 | custom_query: Mapping[str, object] | None = None, |
| 994 | middleware: Sequence[MiddlewareInput] | None = None, |
| 995 | _strict_response_validation: bool, |
| 996 | ) -> None: |
| 997 | if not is_given(timeout): |
| 998 | # if the user passed in a custom http client with a non-default |
| 999 | # timeout set then we use that timeout. |
| 1000 | # |
| 1001 | # note: there is an edge case here where the user passes in a client |
| 1002 | # where they've explicitly set the timeout to match the default timeout |
| 1003 | # as this check is structural, meaning that we'll think they didn't |
| 1004 | # pass in a timeout and will ignore it |
| 1005 | if http_client and http_client.timeout != HTTPX_DEFAULT_TIMEOUT: |
| 1006 | timeout = http_client.timeout |
| 1007 | else: |
| 1008 | timeout = DEFAULT_TIMEOUT |
| 1009 | |
| 1010 | if http_client is not None and not isinstance(http_client, httpx.Client): # pyright: ignore[reportUnnecessaryIsInstance] |
| 1011 | raise TypeError( |
| 1012 | f"Invalid `http_client` argument; Expected an instance of `httpx.Client` but got {type(http_client)}" |
| 1013 | ) |
| 1014 | |
| 1015 | # materialize the middleware before validating it so that passing an |
| 1016 | # iterator/generator doesn't result in validation consuming it and the |
| 1017 | # middleware silently never running |
| 1018 | middleware = tuple(middleware or ()) |
| 1019 | if middleware: |
| 1020 | validate_sync_middleware(middleware) |
| 1021 | |
| 1022 | super().__init__( |
| 1023 | version=version, |
| 1024 | # cast to a valid type because mypy doesn't understand our type narrowing |
| 1025 | timeout=cast(Timeout, timeout), |
| 1026 | base_url=base_url, |
| 1027 | max_retries=max_retries, |
| 1028 | custom_query=custom_query, |
| 1029 | custom_headers=custom_headers, |
| 1030 | middleware=middleware, |
| 1031 | _strict_response_validation=_strict_response_validation, |
| 1032 | ) |
| 1033 | self._middleware_chain = self._build_middleware_chain() |
| 1034 | self._client = http_client or SyncHttpxClientWrapper( |
| 1035 | base_url=base_url, |
| 1036 | # cast to a valid type because mypy doesn't understand our type narrowing |
| 1037 | timeout=cast(Timeout, timeout), |
| 1038 | ) |
| 1039 | |
| 1040 | def is_closed(self) -> bool: |
| 1041 | return self._client.is_closed |
nothing calls this directly
no test coverage detected