(
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,
_strict_response_validation: bool,
)
| 867 | _default_stream_cls: type[Stream[Any]] | None = None |
| 868 | |
| 869 | def __init__( |
| 870 | self, |
| 871 | *, |
| 872 | version: str, |
| 873 | base_url: str | URL, |
| 874 | max_retries: int = DEFAULT_MAX_RETRIES, |
| 875 | timeout: float | Timeout | None | NotGiven = not_given, |
| 876 | http_client: httpx.Client | None = None, |
| 877 | custom_headers: Mapping[str, str] | None = None, |
| 878 | custom_query: Mapping[str, object] | None = None, |
| 879 | _strict_response_validation: bool, |
| 880 | ) -> None: |
| 881 | if not is_given(timeout): |
| 882 | class="cm"># if the user passed in a custom http client with a non-default |
| 883 | class="cm"># timeout set then we use that timeout. |
| 884 | class="cm"># |
| 885 | class="cm"># note: there is an edge case here where the user passes in a client |
| 886 | class="cm"># where they've explicitly set the timeout to match the default timeout |
| 887 | class="cm"># as this check is structural, meaning that weclass="st">'ll think they didn't |
| 888 | class="cm"># pass in a timeout and will ignore it |
| 889 | if http_client and http_client.timeout != HTTPX_DEFAULT_TIMEOUT: |
| 890 | timeout = http_client.timeout |
| 891 | else: |
| 892 | timeout = DEFAULT_TIMEOUT |
| 893 | |
| 894 | if http_client is not None and not isinstance(http_client, httpx.Client): class="cm"># pyright: ignore[reportUnnecessaryIsInstance] |
| 895 | raise TypeError( |
| 896 | fclass="st">"Invalid `http_client` argument; Expected an instance of `httpx.Client` but got {type(http_client)}" |
| 897 | ) |
| 898 | |
| 899 | super().__init__( |
| 900 | version=version, |
| 901 | class="cm"># cast to a valid type because mypy doesn't understand our type narrowing |
| 902 | timeout=cast(Timeout, timeout), |
| 903 | base_url=base_url, |
| 904 | max_retries=max_retries, |
| 905 | custom_query=custom_query, |
| 906 | custom_headers=custom_headers, |
| 907 | _strict_response_validation=_strict_response_validation, |
| 908 | ) |
| 909 | self._client = http_client or SyncHttpxClientWrapper( |
| 910 | base_url=base_url, |
| 911 | class="cm"># cast to a valid type because mypy doesn't understand our type narrowing |
| 912 | timeout=cast(Timeout, timeout), |
| 913 | ) |
| 914 | |
| 915 | def is_closed(self) -> bool: |
| 916 | return self._client.is_closed |
nothing calls this directly
no test coverage detected