Skip to content

Commit f077610

Browse files
committed
Use if TYPE_CHECKING
Change-Id: I63c4c7909f7d7060a4b557f41cff4ba9010e004c
1 parent 566e8a8 commit f077610

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

google/generativeai/vision_models/_vision_models.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,22 @@
3434
from proto.marshal.collections import repeated
3535

3636

37-
# pylint: disable=g-import-not-at-top
38-
try:
37+
# pylint: disable=g-import-not-at-top\
38+
if typing.TYPE_CHECKING:
3939
from IPython import display as IPython_display
40-
except ImportError:
41-
IPython_display = None
42-
43-
try:
44-
from PIL import Image as PIL_Image
45-
except ImportError:
46-
PIL_Image = None
40+
else:
41+
try:
42+
from IPython import display as IPython_display
43+
except ImportError:
44+
IPython_display = None
45+
46+
if typing.TYPE_CHECKING:
47+
import PIL.Image as PIL_Image
48+
else:
49+
try:
50+
from PIL import Image as PIL_Image
51+
except ImportError:
52+
PIL_Image = None
4753

4854

4955
# This is to get around https://github.com/googleapis/proto-plus-python/issues/488

0 commit comments

Comments
 (0)