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

Method copy

src/opencode_ai/_client.py:123–166  ·  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.Client | 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

121 }
122
123 def copy(
124 self,
125 *,
126 base_url: str | httpx.URL | None = None,
127 timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
128 http_client: httpx.Client | None = None,
129 max_retries: int | NotGiven = NOT_GIVEN,
130 default_headers: Mapping[str, str] | None = None,
131 set_default_headers: Mapping[str, str] | None = None,
132 default_query: Mapping[str, object] | None = None,
133 set_default_query: Mapping[str, object] | None = None,
134 _extra_kwargs: Mapping[str, Any] = {},
135 ) -> Self:
136 """
137 Create a new client instance re-using the same options given to the current client with optional overriding.
138 """
139 if default_headers is not None and set_default_headers is not None:
140 raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
141
142 if default_query is not None and set_default_query is not None:
143 raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
144
145 headers = self._custom_headers
146 if default_headers is not None:
147 headers = {**headers, **default_headers}
148 elif set_default_headers is not None:
149 headers = set_default_headers
150
151 params = self._custom_query
152 if default_query is not None:
153 params = {**params, **default_query}
154 elif set_default_query is not None:
155 params = set_default_query
156
157 http_client = http_client or self._client
158 return self.__class__(
159 base_url=base_url or self.base_url,
160 timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
161 http_client=http_client,
162 max_retries=max_retries if is_given(max_retries) else self.max_retries,
163 default_headers=headers,
164 default_query=params,
165 **_extra_kwargs,
166 )
167
168 # Alias for `copy` for nicer inline usage, e.g.
169 # client.with_options(timeout=10).foo.create(...)

Callers 11

model_copyFunction · 0.45
update_envFunction · 0.45
test_copyMethod · 0.45
build_requestMethod · 0.45
test_copyMethod · 0.45
build_requestMethod · 0.45

Calls 2

is_givenFunction · 0.85
__class__Method · 0.80

Tested by 9

test_copyMethod · 0.36
build_requestMethod · 0.36
test_copyMethod · 0.36
build_requestMethod · 0.36