From 4a6776b3b350790f00c419b7e32c39d1b02bc712 Mon Sep 17 00:00:00 2001 From: Erin La <107987318+giterinhub@users.noreply.github.com> Date: Fri, 24 Jul 2026 08:11:44 +0000 Subject: [PATCH] fix(types, tunings): ignore optional IPython type checking errors (#1761) Related to #1761 Addresses part of https://github.com/googleapis/python-genai/issues/1761 - Add # type: ignore annotations for optional IPython module assignments and untyped calls in types.py and tunings.py - Resolves 9 static analysis mypy type checking failures when ipython is uninstalled or untyped --- google/genai/tunings.py | 10 +++++----- google/genai/types.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/google/genai/tunings.py b/google/genai/tunings.py index f41b89e17..7c800e196 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -3844,9 +3844,9 @@ def _get_ipython_shell_name() -> Union[str, Any]: import sys if 'IPython' in sys.modules: - from IPython import get_ipython + from IPython import get_ipython # type: ignore[attr-defined] - return get_ipython().__class__.__name__ + return get_ipython().__class__.__name__ # type: ignore[no-untyped-call] return '' @staticmethod @@ -3964,10 +3964,10 @@ def _display_link( """ - from IPython.display import display - from IPython.display import HTML + from IPython.display import display # type: ignore[attr-defined] + from IPython.display import HTML # type: ignore[attr-defined] - display(HTML(html)) + display(HTML(html)) # type: ignore[no-untyped-call] @staticmethod def display_experiment_button(experiment: str, project: str) -> None: diff --git a/google/genai/types.py b/google/genai/types.py index d5d04ea46..813e7a977 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -9309,10 +9309,10 @@ def show(self) -> None: try: from IPython import display as IPython_display except ImportError: - IPython_display = None + IPython_display = None # type: ignore[assignment] if IPython_display: - IPython_display.display(self._pil_image) + IPython_display.display(self._pil_image) # type: ignore[no-untyped-call] else: img = self._pil_image if img is not None: @@ -11726,11 +11726,11 @@ def show(self) -> None: try: from IPython import display as IPython_display except ImportError: - IPython_display = None + IPython_display = None # type: ignore[assignment] if IPython_display: - IPython_display.display( - IPython_display.Video( + IPython_display.display( # type: ignore[no-untyped-call] + IPython_display.Video( # type: ignore[no-untyped-call] data=self.video_bytes, mimetype=mime_type, embed=True ) )