Skip to content

Commit 1297832

Browse files
fix(client): accept io.IOBase instances in file params (#134)
1 parent 88e49bc commit 1297832

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/finch/_utils/_utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import io
34
import os
45
import re
56
import inspect
@@ -55,10 +56,10 @@ def _extract_items(
5556
return []
5657

5758
# We have exhausted the path, return the entry we found.
58-
if not isinstance(obj, bytes) and not isinstance(obj, tuple):
59+
if not isinstance(obj, bytes) and not isinstance(obj, tuple) and not isinstance(obj, io.IOBase):
5960
raise RuntimeError(
60-
f"Expected entry at {flattened_key} to be bytes or a tuple but received {type(obj)} instead."
61-
)
61+
f"Expected entry at {flattened_key} to be bytes, an io.IOBase instance or a tuple but received {type(obj)} instead."
62+
) from None
6263

6364
# TODO: validate obj more?
6465
assert flattened_key is not None

0 commit comments

Comments
 (0)