Skip to content

Commit ddcc1c7

Browse files
chore(internal): codegen related update
1 parent b72546a commit ddcc1c7

File tree

3 files changed

+3
-373
lines changed

3 files changed

+3
-373
lines changed

src/finch/_base_client.py

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import inspect
1010
import logging
1111
import platform
12-
import warnings
1312
import email.utils
1413
from types import TracebackType
1514
from random import random
@@ -36,7 +35,7 @@
3635
import httpx
3736
import distro
3837
import pydantic
39-
from httpx import URL, Limits
38+
from httpx import URL
4039
from pydantic import PrivateAttr
4140

4241
from . import _exceptions
@@ -51,13 +50,10 @@
5150
Timeout,
5251
NotGiven,
5352
ResponseT,
54-
Transport,
5553
AnyMapping,
5654
PostParser,
57-
ProxiesTypes,
5855
RequestFiles,
5956
HttpxSendArgs,
60-
AsyncTransport,
6157
RequestOptions,
6258
HttpxRequestFiles,
6359
ModelBuilderProtocol,
@@ -338,9 +334,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
338334
_base_url: URL
339335
max_retries: int
340336
timeout: Union[float, Timeout, None]
341-
_limits: httpx.Limits
342-
_proxies: ProxiesTypes | None
343-
_transport: Transport | AsyncTransport | None
344337
_strict_response_validation: bool
345338
_idempotency_header: str | None
346339
_default_stream_cls: type[_DefaultStreamT] | None = None
@@ -353,19 +346,13 @@ def __init__(
353346
_strict_response_validation: bool,
354347
max_retries: int = DEFAULT_MAX_RETRIES,
355348
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
356-
limits: httpx.Limits,
357-
transport: Transport | AsyncTransport | None,
358-
proxies: ProxiesTypes | None,
359349
custom_headers: Mapping[str, str] | None = None,
360350
custom_query: Mapping[str, object] | None = None,
361351
) -> None:
362352
self._version = version
363353
self._base_url = self._enforce_trailing_slash(URL(base_url))
364354
self.max_retries = max_retries
365355
self.timeout = timeout
366-
self._limits = limits
367-
self._proxies = proxies
368-
self._transport = transport
369356
self._custom_headers = custom_headers or {}
370357
self._custom_query = custom_query or {}
371358
self._strict_response_validation = _strict_response_validation
@@ -801,46 +788,11 @@ def __init__(
801788
base_url: str | URL,
802789
max_retries: int = DEFAULT_MAX_RETRIES,
803790
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
804-
transport: Transport | None = None,
805-
proxies: ProxiesTypes | None = None,
806-
limits: Limits | None = None,
807791
http_client: httpx.Client | None = None,
808792
custom_headers: Mapping[str, str] | None = None,
809793
custom_query: Mapping[str, object] | None = None,
810794
_strict_response_validation: bool,
811795
) -> None:
812-
kwargs: dict[str, Any] = {}
813-
if limits is not None:
814-
warnings.warn(
815-
"The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
816-
category=DeprecationWarning,
817-
stacklevel=3,
818-
)
819-
if http_client is not None:
820-
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
821-
else:
822-
limits = DEFAULT_CONNECTION_LIMITS
823-
824-
if transport is not None:
825-
kwargs["transport"] = transport
826-
warnings.warn(
827-
"The `transport` argument is deprecated. The `http_client` argument should be passed instead",
828-
category=DeprecationWarning,
829-
stacklevel=3,
830-
)
831-
if http_client is not None:
832-
raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
833-
834-
if proxies is not None:
835-
kwargs["proxies"] = proxies
836-
warnings.warn(
837-
"The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
838-
category=DeprecationWarning,
839-
stacklevel=3,
840-
)
841-
if http_client is not None:
842-
raise ValueError("The `http_client` argument is mutually exclusive with `proxies`")
843-
844796
if not is_given(timeout):
845797
# if the user passed in a custom http client with a non-default
846798
# timeout set then we use that timeout.
@@ -861,12 +813,9 @@ def __init__(
861813

862814
super().__init__(
863815
version=version,
864-
limits=limits,
865816
# cast to a valid type because mypy doesn't understand our type narrowing
866817
timeout=cast(Timeout, timeout),
867-
proxies=proxies,
868818
base_url=base_url,
869-
transport=transport,
870819
max_retries=max_retries,
871820
custom_query=custom_query,
872821
custom_headers=custom_headers,
@@ -876,9 +825,6 @@ def __init__(
876825
base_url=base_url,
877826
# cast to a valid type because mypy doesn't understand our type narrowing
878827
timeout=cast(Timeout, timeout),
879-
limits=limits,
880-
follow_redirects=True,
881-
**kwargs, # type: ignore
882828
)
883829

884830
def is_closed(self) -> bool:
@@ -1387,45 +1333,10 @@ def __init__(
13871333
_strict_response_validation: bool,
13881334
max_retries: int = DEFAULT_MAX_RETRIES,
13891335
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1390-
transport: AsyncTransport | None = None,
1391-
proxies: ProxiesTypes | None = None,
1392-
limits: Limits | None = None,
13931336
http_client: httpx.AsyncClient | None = None,
13941337
custom_headers: Mapping[str, str] | None = None,
13951338
custom_query: Mapping[str, object] | None = None,
13961339
) -> None:
1397-
kwargs: dict[str, Any] = {}
1398-
if limits is not None:
1399-
warnings.warn(
1400-
"The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
1401-
category=DeprecationWarning,
1402-
stacklevel=3,
1403-
)
1404-
if http_client is not None:
1405-
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
1406-
else:
1407-
limits = DEFAULT_CONNECTION_LIMITS
1408-
1409-
if transport is not None:
1410-
kwargs["transport"] = transport
1411-
warnings.warn(
1412-
"The `transport` argument is deprecated. The `http_client` argument should be passed instead",
1413-
category=DeprecationWarning,
1414-
stacklevel=3,
1415-
)
1416-
if http_client is not None:
1417-
raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
1418-
1419-
if proxies is not None:
1420-
kwargs["proxies"] = proxies
1421-
warnings.warn(
1422-
"The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
1423-
category=DeprecationWarning,
1424-
stacklevel=3,
1425-
)
1426-
if http_client is not None:
1427-
raise ValueError("The `http_client` argument is mutually exclusive with `proxies`")
1428-
14291340
if not is_given(timeout):
14301341
# if the user passed in a custom http client with a non-default
14311342
# timeout set then we use that timeout.
@@ -1447,11 +1358,8 @@ def __init__(
14471358
super().__init__(
14481359
version=version,
14491360
base_url=base_url,
1450-
limits=limits,
14511361
# cast to a valid type because mypy doesn't understand our type narrowing
14521362
timeout=cast(Timeout, timeout),
1453-
proxies=proxies,
1454-
transport=transport,
14551363
max_retries=max_retries,
14561364
custom_query=custom_query,
14571365
custom_headers=custom_headers,
@@ -1461,9 +1369,6 @@ def __init__(
14611369
base_url=base_url,
14621370
# cast to a valid type because mypy doesn't understand our type narrowing
14631371
timeout=cast(Timeout, timeout),
1464-
limits=limits,
1465-
follow_redirects=True,
1466-
**kwargs, # type: ignore
14671372
)
14681373

14691374
def is_closed(self) -> bool:

src/finch/_client.py

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
NotGiven,
2020
Transport,
2121
ProxiesTypes,
22-
AsyncTransport,
2322
RequestOptions,
2423
)
2524
from ._utils import (
@@ -32,11 +31,8 @@
3231
from ._exceptions import APIStatusError
3332
from ._base_client import (
3433
DEFAULT_MAX_RETRIES,
35-
DEFAULT_CONNECTION_LIMITS,
3634
SyncAPIClient,
3735
AsyncAPIClient,
38-
SyncHttpxClientWrapper,
39-
AsyncHttpxClientWrapper,
4036
)
4137
from .resources.hris import hris
4238
from .resources.jobs import jobs
@@ -82,12 +78,6 @@ def __init__(
8278
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
8379
# See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
8480
http_client: httpx.Client | None = None,
85-
# See httpx documentation for [custom transports](https://www.python-httpx.org/advanced/#custom-transports)
86-
transport: Transport | None = None,
87-
# See httpx documentation for [proxies](https://www.python-httpx.org/advanced/#http-proxying)
88-
proxies: ProxiesTypes | None = None,
89-
# See httpx documentation for [limits](https://www.python-httpx.org/advanced/#pool-limit-configuration)
90-
connection_pool_limits: httpx.Limits | None = None,
9181
# Enable or disable schema validation for data returned by the API.
9282
# When enabled an error APIResponseValidationError is raised
9383
# if the API responds with invalid data for the expected schema.
@@ -130,9 +120,6 @@ def __init__(
130120
max_retries=max_retries,
131121
timeout=timeout,
132122
http_client=http_client,
133-
transport=transport,
134-
proxies=proxies,
135-
limits=connection_pool_limits,
136123
custom_headers=default_headers,
137124
custom_query=default_query,
138125
_strict_response_validation=_strict_response_validation,
@@ -217,7 +204,6 @@ def copy(
217204
base_url: str | httpx.URL | None = None,
218205
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
219206
http_client: httpx.Client | None = None,
220-
connection_pool_limits: httpx.Limits | None = None,
221207
max_retries: int | NotGiven = NOT_GIVEN,
222208
default_headers: Mapping[str, str] | None = None,
223209
set_default_headers: Mapping[str, str] | None = None,
@@ -246,24 +232,7 @@ def copy(
246232
elif set_default_query is not None:
247233
params = set_default_query
248234

249-
if connection_pool_limits is not None:
250-
if http_client is not None:
251-
raise ValueError("The 'http_client' argument is mutually exclusive with 'connection_pool_limits'")
252-
253-
if not isinstance(self._client, SyncHttpxClientWrapper):
254-
raise ValueError(
255-
"A custom HTTP client has been set and is mutually exclusive with the 'connection_pool_limits' argument"
256-
)
257-
258-
http_client = None
259-
else:
260-
if self._limits is not DEFAULT_CONNECTION_LIMITS:
261-
connection_pool_limits = self._limits
262-
else:
263-
connection_pool_limits = None
264-
265-
http_client = http_client or self._client
266-
235+
http_client = http_client or self._client
267236
return self.__class__(
268237
access_token=access_token or self.access_token,
269238
client_id=client_id or self.client_id,
@@ -272,7 +241,6 @@ def copy(
272241
base_url=base_url or self.base_url,
273242
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
274243
http_client=http_client,
275-
connection_pool_limits=connection_pool_limits,
276244
max_retries=max_retries if is_given(max_retries) else self.max_retries,
277245
default_headers=headers,
278246
default_query=params,
@@ -352,12 +320,6 @@ def __init__(
352320
# We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
353321
# See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
354322
http_client: httpx.AsyncClient | None = None,
355-
# See httpx documentation for [custom transports](https://www.python-httpx.org/advanced/#custom-transports)
356-
transport: AsyncTransport | None = None,
357-
# See httpx documentation for [proxies](https://www.python-httpx.org/advanced/#http-proxying)
358-
proxies: ProxiesTypes | None = None,
359-
# See httpx documentation for [limits](https://www.python-httpx.org/advanced/#pool-limit-configuration)
360-
connection_pool_limits: httpx.Limits | None = None,
361323
# Enable or disable schema validation for data returned by the API.
362324
# When enabled an error APIResponseValidationError is raised
363325
# if the API responds with invalid data for the expected schema.
@@ -400,9 +362,6 @@ def __init__(
400362
max_retries=max_retries,
401363
timeout=timeout,
402364
http_client=http_client,
403-
transport=transport,
404-
proxies=proxies,
405-
limits=connection_pool_limits,
406365
custom_headers=default_headers,
407366
custom_query=default_query,
408367
_strict_response_validation=_strict_response_validation,
@@ -487,7 +446,6 @@ def copy(
487446
base_url: str | httpx.URL | None = None,
488447
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
489448
http_client: httpx.AsyncClient | None = None,
490-
connection_pool_limits: httpx.Limits | None = None,
491449
max_retries: int | NotGiven = NOT_GIVEN,
492450
default_headers: Mapping[str, str] | None = None,
493451
set_default_headers: Mapping[str, str] | None = None,
@@ -516,24 +474,7 @@ def copy(
516474
elif set_default_query is not None:
517475
params = set_default_query
518476

519-
if connection_pool_limits is not None:
520-
if http_client is not None:
521-
raise ValueError("The 'http_client' argument is mutually exclusive with 'connection_pool_limits'")
522-
523-
if not isinstance(self._client, AsyncHttpxClientWrapper):
524-
raise ValueError(
525-
"A custom HTTP client has been set and is mutually exclusive with the 'connection_pool_limits' argument"
526-
)
527-
528-
http_client = None
529-
else:
530-
if self._limits is not DEFAULT_CONNECTION_LIMITS:
531-
connection_pool_limits = self._limits
532-
else:
533-
connection_pool_limits = None
534-
535-
http_client = http_client or self._client
536-
477+
http_client = http_client or self._client
537478
return self.__class__(
538479
access_token=access_token or self.access_token,
539480
client_id=client_id or self.client_id,
@@ -542,7 +483,6 @@ def copy(
542483
base_url=base_url or self.base_url,
543484
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
544485
http_client=http_client,
545-
connection_pool_limits=connection_pool_limits,
546486
max_retries=max_retries if is_given(max_retries) else self.max_retries,
547487
default_headers=headers,
548488
default_query=params,

0 commit comments

Comments
 (0)