Skip to content

Commit 7f81d21

Browse files
chore(internal): minor style changes (#2043)
1 parent 9b5ea1b commit 7f81d21

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: src/openai/_legacy_response.py

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

205+
origin = get_origin(cast_to) or cast_to
206+
205207
if self._stream:
206208
if to:
207209
if not is_stream_class_type(to):
@@ -258,8 +260,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
258260
if cast_to == bool:
259261
return cast(R, response.text.lower() == "true")
260262

261-
origin = get_origin(cast_to) or cast_to
262-
263263
if inspect.isclass(origin) and issubclass(origin, HttpxBinaryResponseContent):
264264
return cast(R, cast_to(response)) # type: ignore
265265

Diff for: 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)