Skip to content

Commit

Permalink
bail out of upload type checks early for strs
Browse files Browse the repository at this point in the history
Signed-off-by: technillogue <technillogue@gmail.com>
  • Loading branch information
technillogue committed Mar 24, 2024
1 parent 4b85361 commit f963e4f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/cog/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def upload_files(obj: Any, upload_file: Callable[[io.IOBase], str]) -> Any:
When a file is encountered, it will be passed to upload_file. Any paths will be opened and converted to files.
"""
# skip four isinstance checks for fast text models
if type(obj) == str: # noqa: E721
return obj
if isinstance(obj, dict):
return {key: upload_files(value, upload_file) for key, value in obj.items()}
if isinstance(obj, list):
Expand Down

0 comments on commit f963e4f

Please sign in to comment.