From cf581bf3277bd7822cc74182829d89bd2d3ddc62 Mon Sep 17 00:00:00 2001 From: kerry Date: Sun, 20 Sep 2026 05:32:24 +0000 Subject: [PATCH] refactor(fal_ai): drop redundant hasattr guards in the image edit byte reader Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/fal_ai/image_edit/transformation.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/litellm/llms/fal_ai/image_edit/transformation.py b/litellm/llms/fal_ai/image_edit/transformation.py index 274e166e9f6..3879ef0715c 100644 --- a/litellm/llms/fal_ai/image_edit/transformation.py +++ b/litellm/llms/fal_ai/image_edit/transformation.py @@ -58,15 +58,13 @@ def _read_image_bytes(image: object) -> bytes: return _read_image_bytes(image[1]) if isinstance(image, os.PathLike): return Path(image).read_bytes() - if isinstance(image, str): + if isinstance(image, str) or not isinstance(image, _Readable): raise ValueError(f"Unsupported image type for Fal AI image edit: {type(image).__name__}") - if not hasattr(image, "read") or not isinstance(image, _Readable): - raise ValueError(f"Unsupported image type for Fal AI image edit: {type(image).__name__}") - position: Final = image.tell() if hasattr(image, "tell") and isinstance(image, _Tellable) else 0 - if hasattr(image, "seek") and isinstance(image, _Seekable): + position: Final = image.tell() if isinstance(image, _Tellable) else 0 + if isinstance(image, _Seekable): image.seek(0) data: Final = image.read() - if hasattr(image, "seek") and isinstance(image, _Seekable): + if isinstance(image, _Seekable): image.seek(position) return data