Skip to content

Commit 00fe295

Browse files
chore(client): improve copy method (#193)
1 parent 8f03e74 commit 00fe295

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/finch/_client.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import os
66
import asyncio
7-
from typing import Union, Mapping
8-
from typing_extensions import override
7+
from typing import Any, Union, Mapping
8+
from typing_extensions import Self, override
99

1010
import httpx
1111

@@ -187,12 +187,10 @@ def copy(
187187
set_default_headers: Mapping[str, str] | None = None,
188188
default_query: Mapping[str, object] | None = None,
189189
set_default_query: Mapping[str, object] | None = None,
190-
) -> Finch:
190+
_extra_kwargs: Mapping[str, Any] = {},
191+
) -> Self:
191192
"""
192193
Create a new client instance re-using the same options given to the current client with optional overriding.
193-
194-
It should be noted that this does not share the underlying httpx client class which may lead
195-
to performance issues.
196194
"""
197195
if default_headers is not None and set_default_headers is not None:
198196
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
@@ -242,6 +240,7 @@ def copy(
242240
max_retries=max_retries if is_given(max_retries) else self.max_retries,
243241
default_headers=headers,
244242
default_query=params,
243+
**_extra_kwargs,
245244
)
246245

247246
# Alias for `copy` for nicer inline usage, e.g.
@@ -491,12 +490,10 @@ def copy(
491490
set_default_headers: Mapping[str, str] | None = None,
492491
default_query: Mapping[str, object] | None = None,
493492
set_default_query: Mapping[str, object] | None = None,
494-
) -> AsyncFinch:
493+
_extra_kwargs: Mapping[str, Any] = {},
494+
) -> Self:
495495
"""
496496
Create a new client instance re-using the same options given to the current client with optional overriding.
497-
498-
It should be noted that this does not share the underlying httpx client class which may lead
499-
to performance issues.
500497
"""
501498
if default_headers is not None and set_default_headers is not None:
502499
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
@@ -546,6 +543,7 @@ def copy(
546543
max_retries=max_retries if is_given(max_retries) else self.max_retries,
547544
default_headers=headers,
548545
default_query=params,
546+
**_extra_kwargs,
549547
)
550548

551549
# Alias for `copy` for nicer inline usage, e.g.

0 commit comments

Comments
 (0)