spitch 1.22.0__py3-none-any.whl → 1.23.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/_response.py CHANGED
@@ -126,11 +126,11 @@ class BaseAPIResponse(Generic[R]):
126
126
  )
127
127
 
128
128
  def _parse(self, *, to: type[_T] | None = None) -> R | _T:
129
- # unwrap `Annotated[T, ...]` -> `T`
130
- if to and is_annotated_type(to):
131
- to = extract_type_arg(to, 0)
129
+ cast_to = to if to is not None else self._cast_to
132
130
 
133
- origin = get_origin(cast_to) or cast_to
131
+ # unwrap `Annotated[T, ...]` -> `T`
132
+ if cast_to and is_annotated_type(cast_to):
133
+ cast_to = extract_type_arg(cast_to, 0)
134
134
 
135
135
  if self._is_sse_stream:
136
136
  if to:
@@ -166,18 +166,12 @@ class BaseAPIResponse(Generic[R]):
166
166
  return cast(
167
167
  R,
168
168
  stream_cls(
169
- cast_to=self._cast_to,
169
+ cast_to=cast_to,
170
170
  response=self.http_response,
171
171
  client=cast(Any, self._client),
172
172
  ),
173
173
  )
174
174
 
175
- cast_to = to if to is not None else self._cast_to
176
-
177
- # unwrap `Annotated[T, ...]` -> `T`
178
- if is_annotated_type(cast_to):
179
- cast_to = extract_type_arg(cast_to, 0)
180
-
181
175
  if cast_to is NoneType:
182
176
  return cast(R, None)
183
177
 
@@ -197,6 +191,12 @@ class BaseAPIResponse(Generic[R]):
197
191
  if cast_to == bool:
198
192
  return cast(R, response.text.lower() == "true")
199
193
 
194
+ origin = get_origin(cast_to) or cast_to
195
+
196
+ # handle the legacy binary response case
197
+ if inspect.isclass(cast_to) and cast_to.__name__ == "HttpxBinaryResponseContent":
198
+ return cast(R, cast_to(response)) # type: ignore
199
+
200
200
  if origin == APIResponse:
201
201
  raise RuntimeError("Unexpected state - cast_to is `APIResponse`")
202
202
 
@@ -210,14 +210,8 @@ class BaseAPIResponse(Generic[R]):
210
210
  raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`")
211
211
  return cast(R, response)
212
212
 
213
- if (
214
- inspect.isclass(
215
- origin # pyright: ignore[reportUnknownArgumentType]
216
- )
217
- and not issubclass(origin, BaseModel)
218
- and issubclass(origin, pydantic.BaseModel)
219
- ):
220
- raise TypeError("Pydantic models must subclass our base model type, e.g. `from spitch import BaseModel`")
213
+ if inspect.isclass(origin) and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel):
214
+ raise TypeError("Pydantic models must subclass our base model type, e.g. `from openai import BaseModel`")
221
215
 
222
216
  if (
223
217
  cast_to is not object
spitch/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "spitch"
4
- __version__ = "1.22.0" # x-release-please-version
4
+ __version__ = "1.23.0" # x-release-please-version
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spitch
3
- Version: 1.22.0
3
+ Version: 1.23.0
4
4
  Summary: The official Python library for the spitch API
5
5
  Project-URL: Homepage, https://github.com/spi-tch/spitch-python
6
6
  Project-URL: Repository, https://github.com/spi-tch/spitch-python
7
- Author-email: Spitch <hello@spitch.app>
7
+ Author-email: Spitch <developer@spitch.app>
8
8
  License-Expression: Apache-2.0
9
9
  License-File: LICENSE
10
10
  Classifier: Intended Audience :: Developers
@@ -8,10 +8,10 @@ spitch/_files.py,sha256=wV8OmI8oHeNVRtF-7aAEu22jtRG4FzjOioE8lBp-jNA,3617
8
8
  spitch/_models.py,sha256=l6MV_1qor7alt-wmx365DEIjAUYGxkrbwc2slEkyJ-I,28765
9
9
  spitch/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
10
10
  spitch/_resource.py,sha256=TLFPcOOmtxZOQLh3XCNPB_BdrQpp0MIYoKoH52aRAu8,1100
11
- spitch/_response.py,sha256=F9KG5S6W8E3U7Rg9Arb0PqDYly_VlaC1ul6W1UgInQo,28733
11
+ spitch/_response.py,sha256=WRS0cmruHM6LqKngzTsVJ709QJnkAVuVqRr4BOZQ-fE,28698
12
12
  spitch/_streaming.py,sha256=5SpId2EIfF8Ee8UUYmJxqgHUGP1ZdHCUHhHCdNJREFA,10100
13
13
  spitch/_types.py,sha256=uuSZot9wXgdAMJzfF3raLmt3DvhThG7skqUC98_Dm1k,6167
14
- spitch/_version.py,sha256=nBUq6NlmMnFIvSOdP_hBLxvIdhs-7wUfqxkUiutoU6Y,159
14
+ spitch/_version.py,sha256=gzV703X1zmibcIld3hgxtcYg487n64Gf0u_BKH-yPVs,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
@@ -34,7 +34,7 @@ spitch/types/text_tone_mark_params.py,sha256=63P5VElxanYkDP1ZLEuQt97JSgVpMCaAo4W
34
34
  spitch/types/text_tone_mark_response.py,sha256=WGxZsBxLceZ03VM5dafZshp6azdDxpNHcJHhBX7A5DY,277
35
35
  spitch/types/text_translate_params.py,sha256=rU5hbTyBaP5L_akmgswHoNLcTKWN0Gz1kL1yt3EQL44,404
36
36
  spitch/types/text_translate_response.py,sha256=Az3QSpvarlCNTiB7uVzMH21YoWHWJMBEvgdKgVJZW4M,279
37
- spitch-1.22.0.dist-info/METADATA,sha256=I59AuYYtqZ4jOPzO672OIpB_KhP9Sp9r7jJ8L0d3T1I,13287
38
- spitch-1.22.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
- spitch-1.22.0.dist-info/licenses/LICENSE,sha256=C0lDWY-no8IxmnqzQA9BA7Z8jeh_bogVPfeWSgeDDcc,11336
40
- spitch-1.22.0.dist-info/RECORD,,
37
+ spitch-1.23.0.dist-info/METADATA,sha256=jQrkqdOY-Fk-XXbkCcLA0OYQRGBg7zhh0XJUq1QdtG0,13291
38
+ spitch-1.23.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
+ spitch-1.23.0.dist-info/licenses/LICENSE,sha256=C0lDWY-no8IxmnqzQA9BA7Z8jeh_bogVPfeWSgeDDcc,11336
40
+ spitch-1.23.0.dist-info/RECORD,,