|
4 | 4 |
|
5 | 5 | import os
|
6 | 6 | 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 |
9 | 9 |
|
10 | 10 | import httpx
|
11 | 11 |
|
@@ -187,12 +187,10 @@ def copy(
|
187 | 187 | set_default_headers: Mapping[str, str] | None = None,
|
188 | 188 | default_query: Mapping[str, object] | None = None,
|
189 | 189 | set_default_query: Mapping[str, object] | None = None,
|
190 |
| - ) -> Finch: |
| 190 | + _extra_kwargs: Mapping[str, Any] = {}, |
| 191 | + ) -> Self: |
191 | 192 | """
|
192 | 193 | 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. |
196 | 194 | """
|
197 | 195 | if default_headers is not None and set_default_headers is not None:
|
198 | 196 | raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
@@ -242,6 +240,7 @@ def copy(
|
242 | 240 | max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
243 | 241 | default_headers=headers,
|
244 | 242 | default_query=params,
|
| 243 | + **_extra_kwargs, |
245 | 244 | )
|
246 | 245 |
|
247 | 246 | # Alias for `copy` for nicer inline usage, e.g.
|
@@ -491,12 +490,10 @@ def copy(
|
491 | 490 | set_default_headers: Mapping[str, str] | None = None,
|
492 | 491 | default_query: Mapping[str, object] | None = None,
|
493 | 492 | set_default_query: Mapping[str, object] | None = None,
|
494 |
| - ) -> AsyncFinch: |
| 493 | + _extra_kwargs: Mapping[str, Any] = {}, |
| 494 | + ) -> Self: |
495 | 495 | """
|
496 | 496 | 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. |
500 | 497 | """
|
501 | 498 | if default_headers is not None and set_default_headers is not None:
|
502 | 499 | raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
@@ -546,6 +543,7 @@ def copy(
|
546 | 543 | max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
547 | 544 | default_headers=headers,
|
548 | 545 | default_query=params,
|
| 546 | + **_extra_kwargs, |
549 | 547 | )
|
550 | 548 |
|
551 | 549 | # Alias for `copy` for nicer inline usage, e.g.
|
|
0 commit comments