diff --git a/src/funcchain/syntax/input_types.py b/src/funcchain/syntax/input_types.py index 9833718..ebf95f8 100644 --- a/src/funcchain/syntax/input_types.py +++ b/src/funcchain/syntax/input_types.py @@ -8,8 +8,10 @@ if TYPE_CHECKING: from PIL.Image import Image as PImage + from PIL.Image import open as pil_open else: PImage = type("PImage") + pil_open = lambda x: x # noqa class Image: @@ -63,10 +65,10 @@ def to_bytes(self) -> bytes: return base64.b64decode(base64_str) def to_pillow(self) -> PImage: - from io import BytesIO # type: ignore + from io import BytesIO image_bytes = self.to_bytes() - return PImage.open(BytesIO(image_bytes)) + return pil_open(BytesIO(image_bytes)) def to_file(self, path: str) -> None: open(path, "wb").write(self.to_bytes())