diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml index 8a110616b..89cb1a6f5 100644 --- a/.github/workflows/import.yml +++ b/.github/workflows/import.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] + python-version: ['3.11', '3.12', '3.13', '3.14', '3.15'] steps: - name: Checkout repository diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 40a19eb98..c096bc4fe 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] + python-version: ['3.11', '3.12', '3.13', '3.14', '3.15'] steps: - name: Checkout code diff --git a/google/genai/types.py b/google/genai/types.py index 70fdf9227..7a18e2a6d 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -25,7 +25,7 @@ import sys import types as builtin_types import typing -from typing import Annotated, Any, Callable, Dict, List, Literal, Optional, Sequence, Union, _UnionGenericAlias # type: ignore +from typing import Annotated, Any, Callable, Dict, List, Literal, Optional, Sequence, Union import pydantic from pydantic import ConfigDict, Field, PrivateAttr, WrapValidator, model_validator from typing_extensions import Self, TypedDict @@ -37,14 +37,20 @@ _UploadToFileSearchStoreOperation_from_mldev, ) -if sys.version_info >= (3, 10): - # Supports both Union[t1, t2] and t1 | t2 - VersionedUnionType = Union[builtin_types.UnionType, _UnionGenericAlias] +if typing.TYPE_CHECKING: + # Type checkers have always seen this as Any, which lets SchemaUnion accept + # any schema (e.g. Optional[X]). Keep it that way. + VersionedUnionType = Any + _UNION_TYPES = (typing.Union, builtin_types.UnionType) +elif sys.version_info >= (3, 14): + # Union[t1, t2] and t1 | t2 both create builtin_types.UnionType, and + # typing._UnionGenericAlias is deprecated. + VersionedUnionType = builtin_types.UnionType _UNION_TYPES = (typing.Union, builtin_types.UnionType) else: - # Supports only Union[t1, t2] - VersionedUnionType = _UnionGenericAlias - _UNION_TYPES = (typing.Union,) + # Supports both Union[t1, t2] and t1 | t2 + VersionedUnionType = Union[builtin_types.UnionType, typing._UnionGenericAlias] # type: ignore + _UNION_TYPES = (typing.Union, builtin_types.UnionType) _is_pillow_image_imported = False if typing.TYPE_CHECKING: diff --git a/pyproject.toml b/pyproject.toml index 0ca787c15..21c03645a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ version = "2.33.0" description = "GenAI Python SDK" readme = "README.md" license = "Apache-2.0" -requires-python = ">=3.10" +requires-python = ">=3.11" authors = [ { name = "Google LLC", email = "googleapis-packages@google.com" }, ] @@ -16,11 +16,11 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules", ] diff --git a/requirements.txt b/requirements.txt index 4583be06a..c8f6e0aa4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,13 +12,16 @@ google-auth==2.56.0 idna==3.18 iniconfig==2.0.0 packaging==24.2 -pillow==11.0.0 +pillow==11.0.0; python_version < '3.15' +pillow==12.3.0; python_version >= '3.15' pluggy==1.5.0 py==1.11.0 pyasn1==0.6.1 pyasn1_modules==0.4.1 -pydantic==2.12.0 -pydantic_core==2.41.1 +pydantic==2.12.0; python_version < '3.15' +pydantic==2.14.1; python_version >= '3.15' +pydantic_core==2.41.1; python_version < '3.15' +pydantic_core==2.50.1; python_version >= '3.15' pyopenssl==24.2.1 pytest==8.3.4 pytest-asyncio==0.25.0