Skip to content

Commit e339835

Browse files
committed
simplify typing.
Change-Id: I1b901cc40b4b029cb09699fc6eac77690622b6e8
1 parent 17b5d56 commit e339835

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

google/generativeai/types/content_types.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,23 @@
3737
IMAGE_TYPES = (PIL.Image.Image, IPython.display.Image)
3838
ImageType = PIL.Image.Image | IPython.display.Image
3939
else:
40+
IMAGE_TYPES = ()
4041
try:
4142
import PIL.Image
4243
import PIL.ImageFile
44+
45+
IMAGE_TYPES = IMAGE_TYPES + (PIL.Image.Image,)
4346
except ImportError:
4447
PIL = None
4548

4649
try:
4750
import IPython.display
51+
52+
IMAGE_TYPES = IMAGE_TYPES + (IPython.display.Image,)
4853
except ImportError:
4954
IPython = None
5055

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
56+
ImageType = Union["PIL.Image.Image", "IPython.display.Image"]
6357

6458

6559
__all__ = [

0 commit comments

Comments
 (0)