googleapis / googleapis/python-genai

DeprecationWarning: '_UnionGenericAlias' is deprecated and slated for removal in Python 3.17

Open
#1,640 5 comments 13 reactions 1 assignee Assigned to @kkorpal View on GitHub
priority: p2 type: bug
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

#### Environment details

- Programming language: Python
- OS: Linux 6.17.6+deb14-amd64
- Language runtime version: Python 3.14.0
- Package version: google-genai version: 1.49.0

#### Steps to reproduce

1. Run the script: `python test_genai_deprecation.py`
2. Observe deprecation warning:
```
/home/ilvez/.local/share/mise/installs/python/3.14.0/lib/python3.14/site-packages/google/genai/types.py:43: DeprecationWarning: '_UnionGenericAlias' is deprecated and slated for removal in Python 3.17
VersionedUnionType = Union[builtin_types.UnionType, _UnionGenericAlias]
```

The script:
```python
"""
Issue: '_UnionGenericAlias' is deprecated and slated for removal in Python 3.17
Location: google/genai/types.py:43

To reproduce:
1. Install: pip install google-genai==1.49.0
2. Run: python -W default test_genai_deprecation.py

Expected output: DeprecationWarning about '_UnionGenericAlias'
"""

import warnings

# Enable all warnings to ensure DeprecationWarning is shown
warnings.filterwarnings('default', category=DeprecationWarning)

# Simply importing google.genai triggers the deprecation warning
import google.genai # noqa: F401

print("Import successful. Check above for DeprecationWarning.")
print(f"Python version: {__import__('sys').version}")
print(f"google-genai version: {google.genai.__version__}")
```

Example of running with 3.13 and 3.14:
```
% python test_genai_deprecation.py
Import successful. Check above for DeprecationWarning.
Python version: 3.13.8 (main, Oct 10 2025, 12:48:21) [Clang 20.1.4 ]
google-genai version: 1.49.0

% mise use -g python@3.14
mise ~/.config/mise/config.toml tools: python@3.14.0

% python test_genai_deprecation.py
/home/ilvez/.local/share/mise/installs/python/3.14.0/lib/python3.14/site-packages/google/genai/types.py:43: DeprecationWarning: '_UnionGenericAlias' is deprecated and slated for removal in Python 3.17
VersionedUnionType = Union[builtin_types.UnionType, _UnionGenericAlias]
Import successful. Check above for DeprecationWarning.
Python version: 3.14.0 (main, Oct 31 2025, 23:03:06) [Clang 21.1.4 ]
google-genai version: 1.49.0
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.