Skip to content

Commit 78ec5e8

Browse files
committed
fix typing
Change-Id: Ib026f3b66fb44c6ad35a15030b03204306b35443
1 parent e8d69a8 commit 78ec5e8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

google/generativeai/types/content_types.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,29 @@
3737
IMAGE_TYPES = (PIL.Image.Image, IPython.display.Image)
3838
ImageType = PIL.Image.Image | IPython.display.Image
3939
else:
40-
IMAGE_TYPES = ()
4140
try:
4241
import PIL.Image
4342
import PIL.ImageFile
44-
45-
IMAGE_TYPES = IMAGE_TYPES + (PIL.Image.Image,)
4643
except ImportError:
4744
PIL = None
4845

4946
try:
5047
import IPython.display
51-
52-
IMAGE_TYPES = IMAGE_TYPES + (IPython.display.Image,)
5348
except ImportError:
5449
IPython = None
5550

56-
ImageType = Union[*IMAGE_TYPES]
51+
if PIL is not None and IPython is not None:
52+
IMAGE_TYPES = ( PIL.Image.Image, IPython.display.Image)
53+
ImageType = Union[PIL.Image.Image, IPython.display.Image]
54+
elif PIL is not None and IPython is None:
55+
IMAGE_TYPES = (PIL.Image.Image,)
56+
ImageType = Union[PIL.Image.Image]
57+
elif PIL is None and IPython is not None:
58+
IMAGE_TYPES = (IPython.display.Image,)
59+
ImageType = Union[IPython.display.Image,]
60+
else:
61+
IMAGE_TYPES=()
62+
ImageType=Union
5763

5864

5965
__all__ = [

0 commit comments

Comments
 (0)