MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / copy

Method copy

src/opencode_ai/_client.py:284–327  ·  view source on GitHub ↗

Create a new client instance re-using the same options given to the current client with optional overriding.

(
        self,
        *,
        base_url: str | httpx.URL | None = None,
        timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
        http_client: httpx.AsyncClient | None = None,
        max_retries: int | NotGiven = NOT_GIVEN,
        default_headers: Mapping[str, str] | None = None,
        set_default_headers: Mapping[str, str] | None = None,
        default_query: Mapping[str, object] | None = None,
        set_default_query: Mapping[str, object] | None = None,
        _extra_kwargs: Mapping[str, Any] = {},
    )

Source from the content-addressed store, hash-verified

282 }
283
284 def copy(
285 self,
286 *,
287 base_url: str | httpx.URL | None = None,
288 timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
289 http_client: httpx.AsyncClient | None = None,
290 max_retries: int | NotGiven = NOT_GIVEN,
291 default_headers: Mapping[str, str] | None = None,
292 set_default_headers: Mapping[str, str] | None = None,
293 default_query: Mapping[str, object] | None = None,
294 set_default_query: Mapping[str, object] | None = None,
295 _extra_kwargs: Mapping[str, Any] = {},
296 ) -> Self:
297 """
298 Create a new client instance re-using the same options given to the current client with optional overriding.
299 """
300 if default_headers is not None and set_default_headers is not None:
301 raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
302
303 if default_query is not None and set_default_query is not None:
304 raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
305
306 headers = self._custom_headers
307 if default_headers is not None:
308 headers = {**headers, **default_headers}
309 elif set_default_headers is not None:
310 headers = set_default_headers
311
312 params = self._custom_query
313 if default_query is not None:
314 params = {**params, **default_query}
315 elif set_default_query is not None:
316 params = set_default_query
317
318 http_client = http_client or self._client
319 return self.__class__(
320 base_url=base_url or self.base_url,
321 timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
322 http_client=http_client,
323 max_retries=max_retries if is_given(max_retries) else self.max_retries,
324 default_headers=headers,
325 default_query=params,
326 **_extra_kwargs,
327 )
328
329 # Alias for `copy` for nicer inline usage, e.g.
330 # client.with_options(timeout=10).foo.create(...)

Calls 2

is_givenFunction · 0.85
__class__Method · 0.80