Skip to content

fix: deeprecation warning about _UnionGenericAlias'#2225

Open
FomalhautWeisszwerg wants to merge 4 commits intogoogleapis:mainfrom
FomalhautWeisszwerg:fix_deprecation_warning__UnionGenericAlias
Open

fix: deeprecation warning about _UnionGenericAlias'#2225
FomalhautWeisszwerg wants to merge 4 commits intogoogleapis:mainfrom
FomalhautWeisszwerg:fix_deprecation_warning__UnionGenericAlias

Conversation

@FomalhautWeisszwerg
Copy link
Copy Markdown

About This Pull Request

Type

fix

Summary

When using google-genai on Python 3.14, following warning is raised

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

This PR fixes the warning reported #1640 and improves future compatibility.

Detail

Currently, google-genai uses the CPython's private object typing._UnionGenericAlias. However typing._UnionGenericAlias is deprecated and planned to remove until Python 3.17. And google-genai required Python >= 3.10 so the fallback branch for Python <= 3.10 no longer needed.

The changes are

  • drop typing._UnionGenericAlias importing
  • remove fallback branch for Python <= 3.10

I hope that I could be of some help, even if only a little.
Thanks for reviewing.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 31, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Mar 31, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:M Code changes between 10-40 lines label Mar 31, 2026
@Venkaiahbabuneelam
Copy link
Copy Markdown

Hi @FomalhautWeisszwerg, Thanks for reaching out us!

I can see that few checks were failed for the above PR, could you please check once.

Thanks

@FomalhautWeisszwerg
Copy link
Copy Markdown
Author

@Venkaiahbabuneelam Thanks for reviewing.

To fix it, I've added # type: ignore because the definition _UNION_TYPES = (typing.Union, builtin_types.UnionType) is just for supporting both Union[t1, t2] and t1 | t2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Code changes between 10-40 lines status:awaiting user response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants