Skip to content

Commit ae3eed5

Browse files
chore(client): improve copy method (#63)
1 parent b1fcf3f commit ae3eed5

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/orb/_client.py

Lines changed: 8 additions & 10 deletions
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

@@ -145,12 +145,10 @@ def copy(
145145
set_default_headers: Mapping[str, str] | None = None,
146146
default_query: Mapping[str, object] | None = None,
147147
set_default_query: Mapping[str, object] | None = None,
148-
) -> Orb:
148+
_extra_kwargs: Mapping[str, Any] = {},
149+
) -> Self:
149150
"""
150151
Create a new client instance re-using the same options given to the current client with optional overriding.
151-
152-
It should be noted that this does not share the underlying httpx client class which may lead
153-
to performance issues.
154152
"""
155153
if default_headers is not None and set_default_headers is not None:
156154
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
@@ -179,6 +177,7 @@ def copy(
179177
max_retries=max_retries if is_given(max_retries) else self.max_retries,
180178
default_headers=headers,
181179
default_query=params,
180+
**_extra_kwargs,
182181
)
183182

184183
# Alias for `copy` for nicer inline usage, e.g.
@@ -383,12 +382,10 @@ def copy(
383382
set_default_headers: Mapping[str, str] | None = None,
384383
default_query: Mapping[str, object] | None = None,
385384
set_default_query: Mapping[str, object] | None = None,
386-
) -> AsyncOrb:
385+
_extra_kwargs: Mapping[str, Any] = {},
386+
) -> Self:
387387
"""
388388
Create a new client instance re-using the same options given to the current client with optional overriding.
389-
390-
It should be noted that this does not share the underlying httpx client class which may lead
391-
to performance issues.
392389
"""
393390
if default_headers is not None and set_default_headers is not None:
394391
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
@@ -417,6 +414,7 @@ def copy(
417414
max_retries=max_retries if is_given(max_retries) else self.max_retries,
418415
default_headers=headers,
419416
default_query=params,
417+
**_extra_kwargs,
420418
)
421419

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

0 commit comments

Comments
 (0)