Skip to content

Commit f397f20

Browse files
chore(internal): codegen related update (#611)
1 parent 2bae32b commit f397f20

File tree

3 files changed

+3
-373
lines changed

3 files changed

+3
-373
lines changed

src/finch/_base_client.py

+1-96
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

+2-62
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
@@ -83,12 +79,6 @@ def __init__(
8379
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
8480
# See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
8581
http_client: httpx.Client | None = None,
86-
# See httpx documentation for [custom transports](https://www.python-httpx.org/advanced/#custom-transports)
87-
transport: Transport | None = None,
88-
# See httpx documentation for [proxies](https://www.python-httpx.org/advanced/#http-proxying)
89-
proxies: ProxiesTypes | None = None,
90-
# See httpx documentation for [limits](https://www.python-httpx.org/advanced/#pool-limit-configuration)
91-
connection_pool_limits: httpx.Limits | None = None,
9282
# Enable or disable schema validation for data returned by the API.
9383
# When enabled an error APIResponseValidationError is raised
9484
# if the API responds with invalid data for the expected schema.
@@ -131,9 +121,6 @@ def __init__(
131121
max_retries=max_retries,
132122
timeout=timeout,
133123
http_client=http_client,
134-
transport=transport,
135-
proxies=proxies,
136-
limits=connection_pool_limits,
137124
custom_headers=default_headers,
138125
custom_query=default_query,
139126
_strict_response_validation=_strict_response_validation,
@@ -219,7 +206,6 @@ def copy(
219206
base_url: str | httpx.URL | None = None,
220207
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
221208
http_client: httpx.Client | None = None,
222-
connection_pool_limits: httpx.Limits | None = None,
223209
max_retries: int | NotGiven = NOT_GIVEN,
224210
default_headers: Mapping[str, str] | None = None,
225211
set_default_headers: Mapping[str, str] | None = None,
@@ -248,24 +234,7 @@ def copy(
248234
elif set_default_query is not None:
249235
params = set_default_query
250236

251-
if connection_pool_limits is not None:
252-
if http_client is not None:
253-
raise ValueError("The 'http_client' argument is mutually exclusive with 'connection_pool_limits'")
254-
255-
if not isinstance(self._client, SyncHttpxClientWrapper):
256-
raise ValueError(
257-
"A custom HTTP client has been set and is mutually exclusive with the 'connection_pool_limits' argument"
258-
)
259-
260-
http_client = None
261-
else:
262-
if self._limits is not DEFAULT_CONNECTION_LIMITS:
263-
connection_pool_limits = self._limits
264-
else:
265-
connection_pool_limits = None
266-
267-
http_client = http_client or self._client
268-
237+
http_client = http_client or self._client
269238
return self.__class__(
270239
access_token=access_token or self.access_token,
271240
client_id=client_id or self.client_id,
@@ -274,7 +243,6 @@ def copy(
274243
base_url=base_url or self.base_url,
275244
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
276245
http_client=http_client,
277-
connection_pool_limits=connection_pool_limits,
278246
max_retries=max_retries if is_given(max_retries) else self.max_retries,
279247
default_headers=headers,
280248
default_query=params,
@@ -419,12 +387,6 @@ def __init__(
419387
# We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
420388
# See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
421389
http_client: httpx.AsyncClient | None = None,
422-
# See httpx documentation for [custom transports](https://www.python-httpx.org/advanced/#custom-transports)
423-
transport: AsyncTransport | None = None,
424-
# See httpx documentation for [proxies](https://www.python-httpx.org/advanced/#http-proxying)
425-
proxies: ProxiesTypes | None = None,
426-
# See httpx documentation for [limits](https://www.python-httpx.org/advanced/#pool-limit-configuration)
427-
connection_pool_limits: httpx.Limits | None = None,
428390
# Enable or disable schema validation for data returned by the API.
429391
# When enabled an error APIResponseValidationError is raised
430392
# if the API responds with invalid data for the expected schema.
@@ -467,9 +429,6 @@ def __init__(
467429
max_retries=max_retries,
468430
timeout=timeout,
469431
http_client=http_client,
470-
transport=transport,
471-
proxies=proxies,
472-
limits=connection_pool_limits,
473432
custom_headers=default_headers,
474433
custom_query=default_query,
475434
_strict_response_validation=_strict_response_validation,
@@ -555,7 +514,6 @@ def copy(
555514
base_url: str | httpx.URL | None = None,
556515
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
557516
http_client: httpx.AsyncClient | None = None,
558-
connection_pool_limits: httpx.Limits | None = None,
559517
max_retries: int | NotGiven = NOT_GIVEN,
560518
default_headers: Mapping[str, str] | None = None,
561519
set_default_headers: Mapping[str, str] | None = None,
@@ -584,24 +542,7 @@ def copy(
584542
elif set_default_query is not None:
585543
params = set_default_query
586544

587-
if connection_pool_limits is not None:
588-
if http_client is not None:
589-
raise ValueError("The 'http_client' argument is mutually exclusive with 'connection_pool_limits'")
590-
591-
if not isinstance(self._client, AsyncHttpxClientWrapper):
592-
raise ValueError(
593-
"A custom HTTP client has been set and is mutually exclusive with the 'connection_pool_limits' argument"
594-
)
595-
596-
http_client = None
597-
else:
598-
if self._limits is not DEFAULT_CONNECTION_LIMITS:
599-
connection_pool_limits = self._limits
600-
else:
601-
connection_pool_limits = None
602-
603-
http_client = http_client or self._client
604-
545+
http_client = http_client or self._client
605546
return self.__class__(
606547
access_token=access_token or self.access_token,
607548
client_id=client_id or self.client_id,
@@ -610,7 +551,6 @@ def copy(
610551
base_url=base_url or self.base_url,
611552
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
612553
http_client=http_client,
613-
connection_pool_limits=connection_pool_limits,
614554
max_retries=max_retries if is_given(max_retries) else self.max_retries,
615555
default_headers=headers,
616556
default_query=params,

0 commit comments

Comments
 (0)