Repository navigation
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
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
- Run the script:
python test_genai_deprecation.py - 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:
"""
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 [email protected]
mise ~/.config/mise/config.toml tools: [email protected]
% 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
Reacted by Daniel Himmelstein, Sebastian Popa, José Enrique Narváez Gago, Justin Sexton, Jose Enrique Narvaez, Bilel Omrani, Michał Zięba, Anuruth Lertpiya, Fomalhaut Weisszwerg, Pascal Corpet and 3 more
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
ilvez commentedon Nov 7, 2025
Not really sure it's something to solve at all (related to how the solution would look like with older Pythons etc..), but just wanted to mark it down so if there's an resolution to this, then at least it's documented.
janasangeetha commentedon Dec 2, 2025
Hey @ilvez
Thank you for bringing this to our attention. We truly appreciate you flagging this issue, we will file a bug internally.
sakshamgoyal-01 commentedon Jul 6, 2026
still waiting on an update on this. It's been months.
python 3.9 is already EOL so you can safely remove that snippet to check python version >=3.10.
the
requires-pythonis already set to >=3.10 so it's completely unnecessary to keep now.if the sdk generator is available on github, I can make a PR for it since the file mentions:
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.janisto commentedon Jul 14, 2026
This is still present in
google-genai==2.11.0on Python 3.14.6.My Firebase Functions application uses
genkit==0.7.0together withgenkit-plugin-google-genai==0.7.0. Importing the Vertex AI plugin:transitively imports
google.genai, which triggers this warning during pytest collection:It is annoying that downstream projects treating warnings as errors must add an exception for an upstream import warning:
I do not have a preference for the internal implementation. However, importing a supported package version on Python 3.14 should not emit a deprecation warning for reliance on a private Python API scheduled for removal in Python 3.17.
eyb1 commentedon Jul 18, 2026
FTR, The latest version as of today (
google-genai 2.12.1) still produces the same warning.fix(code): stop leaking turn coroutines and sqlite handles (#5218)
test: say when to remove the google-genai warning filter
test: fix the flaky hooks timing test and clear the integration warni…
acoustesh commentedon Oct 12, 2026
Still reproducible with google-genai 2.29.0 on Python 3.14.6:
The warning is triggered by the private import on
types.pyline 28 (from typing import ..., _UnionGenericAlias # type: ignore) and its use on line 42.Possible fix: build the alias from public objects instead of the private name:
Alternatively, drop the alias and use the
_UNION_TYPES = (typing.Union, builtin_types.UnionType)tuple already defined on the next line, withtyping.get_origin(x) in _UNION_TYPESfor theisinstancechecks.The same private name is also used in:
google/genai/_extra_utils.py:42(UnionType = typing._UnionGenericAlias)google/genai/_automatic_function_calling_util.py:31(VersionedUnionType = typing._UnionGenericAlias)so those should be updated together.
ilvez commentedon Oct 23, 2026
Wow, just noticed that it's nearly a year open now :-D Birthday soon! 🎂
ilvez commentedon Oct 29, 2026
Oh I jinxed it. No birthday, it seems #3194 solved it.