Skip to content

Commit 89a9dd8

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore(internal): minor style changes (#2043)
1 parent 348a783 commit 89a9dd8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/openai/_legacy_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
205205
if cast_to and is_annotated_type(cast_to):
206206
cast_to = extract_type_arg(cast_to, 0)
207207

208+
origin = get_origin(cast_to) or cast_to
209+
208210
if self._stream:
209211
if to:
210212
if not is_stream_class_type(to):
@@ -261,8 +263,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
261263
if cast_to == bool:
262264
return cast(R, response.text.lower() == "true")
263265

264-
origin = get_origin(cast_to) or cast_to
265-
266266
if inspect.isclass(origin) and issubclass(origin, HttpxBinaryResponseContent):
267267
return cast(R, cast_to(response)) # type: ignore
268268

src/openai/_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
136136
if cast_to and is_annotated_type(cast_to):
137137
cast_to = extract_type_arg(cast_to, 0)
138138

139+
origin = get_origin(cast_to) or cast_to
140+
139141
if self._is_sse_stream:
140142
if to:
141143
if not is_stream_class_type(to):
@@ -195,8 +197,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
195197
if cast_to == bool:
196198
return cast(R, response.text.lower() == "true")
197199

198-
origin = get_origin(cast_to) or cast_to
199-
200200
# handle the legacy binary response case
201201
if inspect.isclass(cast_to) and cast_to.__name__ == "HttpxBinaryResponseContent":
202202
return cast(R, cast_to(response)) # type: ignore

0 commit comments

Comments
 (0)