Skip to content

Commit 71ca257

Browse files
chore(internal): minor style changes (#578)
1 parent a9e3c57 commit 71ca257

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/finch/_legacy_response.py

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

201+
origin = get_origin(cast_to) or cast_to
202+
201203
if self._stream:
202204
if to:
203205
if not is_stream_class_type(to):
@@ -254,8 +256,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
254256
if cast_to == bool:
255257
return cast(R, response.text.lower() == "true")
256258

257-
origin = get_origin(cast_to) or cast_to
258-
259259
if inspect.isclass(origin) and issubclass(origin, HttpxBinaryResponseContent):
260260
return cast(R, cast_to(response)) # type: ignore
261261

src/finch/_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)