Skip to content

Commit fcff47b

Browse files
google-genai-botcopybara-github
authored andcommitted
chore: lazy import yaml in types.py
PiperOrigin-RevId: 831577224
1 parent a220dde commit fcff47b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

google/genai/types.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@
8686

8787
if typing.TYPE_CHECKING:
8888
import yaml
89-
else:
90-
try:
91-
import yaml
92-
except ImportError:
93-
yaml = None
9489

9590
_is_httpx_imported = False
9691
if typing.TYPE_CHECKING:
@@ -10298,7 +10293,9 @@ def to_yaml_file(self, file_path: str, version: Optional[str] = None) -> None:
1029810293
Raises:
1029910294
ImportError: If the pyyaml library is not installed.
1030010295
"""
10301-
if yaml is None:
10296+
try:
10297+
import yaml
10298+
except ImportError:
1030210299
raise ImportError(
1030310300
'YAML serialization requires the pyyaml library. Please install'
1030410301
" it using 'pip install google-cloud-aiplatform[evaluation]'."

0 commit comments

Comments
 (0)