spitch 1.26.0__py3-none-any.whl → 1.27.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spitch might be problematic. Click here for more details.
- spitch/__init__.py +5 -0
- spitch/_base_client.py +22 -2
- spitch/_models.py +2 -0
- spitch/_response.py +1 -1
- spitch/_types.py +2 -0
- spitch/_utils/_proxy.py +4 -1
- spitch/_utils/_resources_proxy.py +24 -0
- spitch/_version.py +1 -1
- {spitch-1.26.0.dist-info → spitch-1.27.0.dist-info}/METADATA +1 -1
- {spitch-1.26.0.dist-info → spitch-1.27.0.dist-info}/RECORD +12 -11
- {spitch-1.26.0.dist-info → spitch-1.27.0.dist-info}/WHEEL +0 -0
- {spitch-1.26.0.dist-info → spitch-1.27.0.dist-info}/licenses/LICENSE +0 -0
spitch/__init__.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
import typing as _t
|
|
4
|
+
|
|
3
5
|
from . import types
|
|
4
6
|
from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
|
|
5
7
|
from ._utils import file_from_path
|
|
@@ -67,6 +69,9 @@ __all__ = [
|
|
|
67
69
|
"DefaultAsyncHttpxClient",
|
|
68
70
|
]
|
|
69
71
|
|
|
72
|
+
if not _t.TYPE_CHECKING:
|
|
73
|
+
from ._utils._resources_proxy import resources as resources
|
|
74
|
+
|
|
70
75
|
_setup_logging()
|
|
71
76
|
|
|
72
77
|
# Update the __module__ attribute for exported symbols so that
|
spitch/_base_client.py
CHANGED
|
@@ -960,6 +960,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
960
960
|
if self.custom_auth is not None:
|
|
961
961
|
kwargs["auth"] = self.custom_auth
|
|
962
962
|
|
|
963
|
+
if options.follow_redirects is not None:
|
|
964
|
+
kwargs["follow_redirects"] = options.follow_redirects
|
|
965
|
+
|
|
963
966
|
log.debug("Sending HTTP Request: %s %s", request.method, request.url)
|
|
964
967
|
|
|
965
968
|
response = None
|
|
@@ -1068,7 +1071,14 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
1068
1071
|
) -> ResponseT:
|
|
1069
1072
|
origin = get_origin(cast_to) or cast_to
|
|
1070
1073
|
|
|
1071
|
-
if
|
|
1074
|
+
if (
|
|
1075
|
+
inspect.isclass(origin)
|
|
1076
|
+
and issubclass(origin, BaseAPIResponse)
|
|
1077
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
|
1078
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
|
1079
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
|
1080
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
|
1081
|
+
):
|
|
1072
1082
|
if not issubclass(origin, APIResponse):
|
|
1073
1083
|
raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}")
|
|
1074
1084
|
|
|
@@ -1464,6 +1474,9 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1464
1474
|
if self.custom_auth is not None:
|
|
1465
1475
|
kwargs["auth"] = self.custom_auth
|
|
1466
1476
|
|
|
1477
|
+
if options.follow_redirects is not None:
|
|
1478
|
+
kwargs["follow_redirects"] = options.follow_redirects
|
|
1479
|
+
|
|
1467
1480
|
log.debug("Sending HTTP Request: %s %s", request.method, request.url)
|
|
1468
1481
|
|
|
1469
1482
|
response = None
|
|
@@ -1572,7 +1585,14 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1572
1585
|
) -> ResponseT:
|
|
1573
1586
|
origin = get_origin(cast_to) or cast_to
|
|
1574
1587
|
|
|
1575
|
-
if
|
|
1588
|
+
if (
|
|
1589
|
+
inspect.isclass(origin)
|
|
1590
|
+
and issubclass(origin, BaseAPIResponse)
|
|
1591
|
+
# we only want to actually return the custom BaseAPIResponse class if we're
|
|
1592
|
+
# returning the raw response, or if we're not streaming SSE, as if we're streaming
|
|
1593
|
+
# SSE then `cast_to` doesn't actively reflect the type we need to parse into
|
|
1594
|
+
and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
|
|
1595
|
+
):
|
|
1576
1596
|
if not issubclass(origin, AsyncAPIResponse):
|
|
1577
1597
|
raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}")
|
|
1578
1598
|
|
spitch/_models.py
CHANGED
|
@@ -733,6 +733,7 @@ class FinalRequestOptionsInput(TypedDict, total=False):
|
|
|
733
733
|
idempotency_key: str
|
|
734
734
|
json_data: Body
|
|
735
735
|
extra_json: AnyMapping
|
|
736
|
+
follow_redirects: bool
|
|
736
737
|
|
|
737
738
|
|
|
738
739
|
@final
|
|
@@ -746,6 +747,7 @@ class FinalRequestOptions(pydantic.BaseModel):
|
|
|
746
747
|
files: Union[HttpxRequestFiles, None] = None
|
|
747
748
|
idempotency_key: Union[str, None] = None
|
|
748
749
|
post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
|
|
750
|
+
follow_redirects: Union[bool, None] = None
|
|
749
751
|
|
|
750
752
|
# It should be noted that we cannot use `json` here as that would override
|
|
751
753
|
# a BaseModel method in an incompatible fashion.
|
spitch/_response.py
CHANGED
|
@@ -227,7 +227,7 @@ class BaseAPIResponse(Generic[R]):
|
|
|
227
227
|
# split is required to handle cases where additional information is included
|
|
228
228
|
# in the response, e.g. application/json; charset=utf-8
|
|
229
229
|
content_type, *_ = response.headers.get("content-type", "*").split(";")
|
|
230
|
-
if content_type
|
|
230
|
+
if not content_type.endswith("json"):
|
|
231
231
|
if is_basemodel(cast_to):
|
|
232
232
|
try:
|
|
233
233
|
data = response.json()
|
spitch/_types.py
CHANGED
|
@@ -100,6 +100,7 @@ class RequestOptions(TypedDict, total=False):
|
|
|
100
100
|
params: Query
|
|
101
101
|
extra_json: AnyMapping
|
|
102
102
|
idempotency_key: str
|
|
103
|
+
follow_redirects: bool
|
|
103
104
|
|
|
104
105
|
|
|
105
106
|
# Sentinel class used until PEP 0661 is accepted
|
|
@@ -217,3 +218,4 @@ class _GenericAlias(Protocol):
|
|
|
217
218
|
|
|
218
219
|
class HttpxSendArgs(TypedDict, total=False):
|
|
219
220
|
auth: httpx.Auth
|
|
221
|
+
follow_redirects: bool
|
spitch/_utils/_proxy.py
CHANGED
|
@@ -46,7 +46,10 @@ class LazyProxy(Generic[T], ABC):
|
|
|
46
46
|
@property # type: ignore
|
|
47
47
|
@override
|
|
48
48
|
def __class__(self) -> type: # pyright: ignore
|
|
49
|
-
|
|
49
|
+
try:
|
|
50
|
+
proxied = self.__get_proxied__()
|
|
51
|
+
except Exception:
|
|
52
|
+
return type(self)
|
|
50
53
|
if issubclass(type(proxied), LazyProxy):
|
|
51
54
|
return type(proxied)
|
|
52
55
|
return proxied.__class__
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
from typing_extensions import override
|
|
5
|
+
|
|
6
|
+
from ._proxy import LazyProxy
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ResourcesProxy(LazyProxy[Any]):
|
|
10
|
+
"""A proxy for the `spitch.resources` module.
|
|
11
|
+
|
|
12
|
+
This is used so that we can lazily import `spitch.resources` only when
|
|
13
|
+
needed *and* so that users can just import `spitch` and reference `spitch.resources`
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
@override
|
|
17
|
+
def __load__(self) -> Any:
|
|
18
|
+
import importlib
|
|
19
|
+
|
|
20
|
+
mod = importlib.import_module("spitch.resources")
|
|
21
|
+
return mod
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
resources = ResourcesProxy().__as_proxied__()
|
spitch/_version.py
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
spitch/__init__.py,sha256=
|
|
2
|
-
spitch/_base_client.py,sha256=
|
|
1
|
+
spitch/__init__.py,sha256=Z4a7OtgmiVP34d5wa0YEk3g_4xYJ43k1mv47KD-eO_Y,2510
|
|
2
|
+
spitch/_base_client.py,sha256=3iXoiv3SggFtiMNIOMdmRtfI7peCQ08wowUoia6p89U,66013
|
|
3
3
|
spitch/_client.py,sha256=edWlodXy44ArTu9KY7M_zXYKMhs66gptWUqSuMwN0SI,15438
|
|
4
4
|
spitch/_compat.py,sha256=fQkXUY7reJc8m_yguMWSjHBfO8lNzw4wOAxtkhP9d1Q,6607
|
|
5
5
|
spitch/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
|
6
6
|
spitch/_exceptions.py,sha256=xsQtKJTiIdz2X1bQDQFZcSW7WBofLazdQm9nMCyPEVM,3220
|
|
7
7
|
spitch/_files.py,sha256=wV8OmI8oHeNVRtF-7aAEu22jtRG4FzjOioE8lBp-jNA,3617
|
|
8
|
-
spitch/_models.py,sha256=
|
|
8
|
+
spitch/_models.py,sha256=AFNOFV0-xr5GbImuRTYFjsaFtYV4NP7o_KLCHj82D-Y,28953
|
|
9
9
|
spitch/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
|
|
10
10
|
spitch/_resource.py,sha256=TLFPcOOmtxZOQLh3XCNPB_BdrQpp0MIYoKoH52aRAu8,1100
|
|
11
|
-
spitch/_response.py,sha256
|
|
11
|
+
spitch/_response.py,sha256=-1LLK1wjPW3Hcro9NXjf_SnPRArU1ozdctNIStvxbWo,28690
|
|
12
12
|
spitch/_streaming.py,sha256=5SpId2EIfF8Ee8UUYmJxqgHUGP1ZdHCUHhHCdNJREFA,10100
|
|
13
|
-
spitch/_types.py,sha256=
|
|
14
|
-
spitch/_version.py,sha256=
|
|
13
|
+
spitch/_types.py,sha256=lccvqVi8E6-4SKt0rn1e9XXNePb0WwdDc10sPVSCygI,6221
|
|
14
|
+
spitch/_version.py,sha256=qnlIa9KJv95IyuCAR3qXA6wWbOpp0o1LVbRCaWmFzz4,159
|
|
15
15
|
spitch/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
spitch/_utils/__init__.py,sha256=k266EatJr88V8Zseb7xUimTlCeno9SynRfLwadHP1b4,2016
|
|
17
17
|
spitch/_utils/_logs.py,sha256=ApRyYK_WgZfEr_ygBUBXWMlTgeMr2tdNOGlH8jE4oJc,774
|
|
18
|
-
spitch/_utils/_proxy.py,sha256=
|
|
18
|
+
spitch/_utils/_proxy.py,sha256=aglnj2yBTDyGX9Akk2crZHrl10oqRmceUy2Zp008XEs,1975
|
|
19
19
|
spitch/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
|
|
20
|
+
spitch/_utils/_resources_proxy.py,sha256=O0A5203gv-9Tg2PzRAYDPjXvJg_FQoaN41auzUUY8NM,589
|
|
20
21
|
spitch/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
|
|
21
22
|
spitch/_utils/_sync.py,sha256=TpGLrrhRNWTJtODNE6Fup3_k7zrWm1j2RlirzBwre-0,2862
|
|
22
23
|
spitch/_utils/_transform.py,sha256=n7kskEWz6o__aoNvhFoGVyDoalNe6mJwp-g7BWkdj88,15617
|
|
@@ -34,7 +35,7 @@ spitch/types/text_tone_mark_params.py,sha256=MEnWzcSjPT_Z_8Mio96LgwYbx2BngG5By-M
|
|
|
34
35
|
spitch/types/text_tone_mark_response.py,sha256=WGxZsBxLceZ03VM5dafZshp6azdDxpNHcJHhBX7A5DY,277
|
|
35
36
|
spitch/types/text_translate_params.py,sha256=skEeG7oTZUSl_gugnqL4Mb7HE_pEFhKNygZPTvci2hA,416
|
|
36
37
|
spitch/types/text_translate_response.py,sha256=Az3QSpvarlCNTiB7uVzMH21YoWHWJMBEvgdKgVJZW4M,279
|
|
37
|
-
spitch-1.
|
|
38
|
-
spitch-1.
|
|
39
|
-
spitch-1.
|
|
40
|
-
spitch-1.
|
|
38
|
+
spitch-1.27.0.dist-info/METADATA,sha256=IfBIUFzsGH5MPVuCD83uBffKuZP9-CfI-TTUH-JfqJY,13253
|
|
39
|
+
spitch-1.27.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
40
|
+
spitch-1.27.0.dist-info/licenses/LICENSE,sha256=C0lDWY-no8IxmnqzQA9BA7Z8jeh_bogVPfeWSgeDDcc,11336
|
|
41
|
+
spitch-1.27.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|