From 5583aa76f9570bef69148ee0f97839b4a5a42524 Mon Sep 17 00:00:00 2001 From: DABH Date: Fri, 31 Jul 2026 14:15:26 -0500 Subject: [PATCH] Remove google-genai compat shim, require 2.12+ google-genai 2.12.0 is now past the two-week exclude-newer window, so the dependency floor can move to >=2.12.0 and the _compat.py shim from #1652 is no longer needed. Interaction is imported from its defining module, which both runtime and type checkers resolve to the resource class (the public google.genai.interactions.Interaction still resolves to a TypeAliasType for type checkers; tracked upstream in googleapis/python-genai#2732). Lockfile: google-genai 2.11.0 -> 2.12.1; google-auth downgraded to 2.55.2 per 2.12.1's google-auth<2.56.0 constraint. --- pyproject.toml | 2 +- temporalio/contrib/google_genai/_compat.py | 24 ------------------- .../contrib/google_genai/_gemini_activity.py | 2 +- .../google_genai/_temporal_interactions.py | 2 +- tests/contrib/google_genai/test_gemini.py | 2 +- uv.lock | 20 ++++++++-------- 6 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 temporalio/contrib/google_genai/_compat.py diff --git a/pyproject.toml b/pyproject.toml index 2303bdf00..b8ce9deae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ lambda-worker-otel = [ "opentelemetry-sdk-extension-aws>=2.0.0,<3", ] aioboto3 = ["aioboto3>=10.4.0", "types-aioboto3[s3]>=10.4.0"] -google-genai = ["google-genai>=2.10.0,<3.0.0"] +google-genai = ["google-genai>=2.12.0,<3.0.0"] strands-agents = ["strands-agents>=1.39.0"] [project.urls] diff --git a/temporalio/contrib/google_genai/_compat.py b/temporalio/contrib/google_genai/_compat.py deleted file mode 100644 index 6613e2b9c..000000000 --- a/temporalio/contrib/google_genai/_compat.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Version-compatibility shims for the ``google-genai`` SDK. - -Single home for workarounds that keep the plugin importable and -type-checkable across the supported ``google-genai`` range; remove entries -as upstream fixes land. -""" - -from __future__ import annotations - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - # google-genai 2.12.0 exports two ``Interaction`` names: the interaction - # resource class and a ``TypeAliasType`` over the trigger-request - # variants. At runtime we get the resource class but type checkers - # resolve to the alias which causes failures (the alias has no ``id``, - # etc.). Force the type checker to see the class' defining module (in - # the same location in 2.10 and 2.12). - from google.genai._gaos.types.interactions.interaction import Interaction -else: - # At runtime, Interaction resolves properly for 2.10 and 2.12 - from google.genai.interactions import Interaction - -__all__ = ["Interaction"] diff --git a/temporalio/contrib/google_genai/_gemini_activity.py b/temporalio/contrib/google_genai/_gemini_activity.py index 496bbf1ab..9a8dd9e07 100644 --- a/temporalio/contrib/google_genai/_gemini_activity.py +++ b/temporalio/contrib/google_genai/_gemini_activity.py @@ -17,11 +17,11 @@ from google.genai import Client as GeminiClient from google.genai import errors as genai_errors from google.genai import types +from google.genai._gaos.types.interactions.interaction import Interaction from google.genai.types import HttpOptions from google.genai.types import HttpResponse as SdkHttpResponse from temporalio import activity -from temporalio.contrib.google_genai._compat import Interaction from temporalio.contrib.google_genai._models import ( _GeminiApiRequest, _GeminiApiResponse, diff --git a/temporalio/contrib/google_genai/_temporal_interactions.py b/temporalio/contrib/google_genai/_temporal_interactions.py index 54d8353cd..9b6b5ffdb 100644 --- a/temporalio/contrib/google_genai/_temporal_interactions.py +++ b/temporalio/contrib/google_genai/_temporal_interactions.py @@ -20,10 +20,10 @@ from typing import Any, cast import pydantic +from google.genai._gaos.types.interactions.interaction import Interaction from google.genai.interactions import InteractionSSEEvent from temporalio import workflow as temporal_workflow -from temporalio.contrib.google_genai._compat import Interaction from temporalio.contrib.google_genai._models import ( _GeminiInteractionIdRequest, _GeminiInteractionRequest, diff --git a/tests/contrib/google_genai/test_gemini.py b/tests/contrib/google_genai/test_gemini.py index 0881f63b3..dea862914 100644 --- a/tests/contrib/google_genai/test_gemini.py +++ b/tests/contrib/google_genai/test_gemini.py @@ -30,6 +30,7 @@ import pytest from google.genai import Client as GeminiClient from google.genai import types +from google.genai._gaos.types.interactions.interaction import Interaction from google.genai.interactions import ( Agent, # pyright: ignore[reportPrivateImportUsage] InteractionSSEEvent, @@ -44,7 +45,6 @@ GoogleGenAIPlugin, activity_as_tool, ) -from temporalio.contrib.google_genai._compat import Interaction from temporalio.contrib.google_genai._models import ( _GeminiApiRequest, _GeminiApiResponse, diff --git a/uv.lock b/uv.lock index c825d5488..df6092c5a 100644 --- a/uv.lock +++ b/uv.lock @@ -9,7 +9,7 @@ resolution-markers = [ ] [options] -exclude-newer = "2026-07-16T16:18:47.494197Z" +exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values. exclude-newer-span = "P2W" [[package]] @@ -986,7 +986,7 @@ name = "exceptiongroup" version = "1.3.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "typing-extensions", marker = "python_full_version < '3.11'" }, + { name = "typing-extensions" }, ] sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" } wheels = [ @@ -1288,15 +1288,15 @@ wheels = [ [[package]] name = "google-auth" -version = "2.56.0" +version = "2.55.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cryptography" }, { name = "pyasn1-modules" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/58/66/b4ba60005743e01933e22b4f62313e063f7460458b7d8a358427b4930013/google_auth-2.56.0.tar.gz", hash = "sha256:f90fa030b569a92654b9d690665a073841df33d57487be53db583a9a0867a553", size = 364629, upload-time = "2026-07-13T19:09:57.143Z" } +sdist = { url = "https://files.pythonhosted.org/packages/79/b9/e370d86fea3da13ec0256df30323dd26c0cb9c8c85f0c6ec42ac9df0106b/google_auth-2.55.2.tar.gz", hash = "sha256:97ae7790ff740f2bc9db60eb864a7804f4ac19f5f02c38b3d942f2fea6e9b9ae", size = 361414, upload-time = "2026-07-07T18:43:21.227Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/a8/7d/cd3e187f14ce832e419e70709bfcc40cb0dc11517d5d03c9d3919bcc3101/google_auth-2.56.0-py3-none-any.whl", hash = "sha256:6e88c10217e07a92bfd01cac8ee99e32ccfb08414c3102e6c5b8d58f37a0d1e0", size = 257976, upload-time = "2026-07-13T19:09:42.685Z" }, + { url = "https://files.pythonhosted.org/packages/1e/c6/02eb5a337ac316a4c30c012e747bad5cea36e1a876efecdf80865541f7d8/google_auth-2.55.2-py3-none-any.whl", hash = "sha256:d715f265f2cafc6a5f1bf0dc19870d20e3119f6f6682785a250bce3d03d38a3b", size = 256778, upload-time = "2026-07-07T18:43:19.52Z" }, ] [package.optional-dependencies] @@ -1309,7 +1309,7 @@ requests = [ [[package]] name = "google-genai" -version = "2.11.0" +version = "2.12.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -1323,9 +1323,9 @@ dependencies = [ { name = "typing-extensions" }, { name = "websockets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/a6/01/e7b5f3aac89200c78318ed7643401e7f5ed3131b0cd353c07483606b1e61/google_genai-2.11.0.tar.gz", hash = "sha256:4c5e524d24b145c96be327f9a7f8f04b0fe4efee0533877795e9848afed01749", size = 622366, upload-time = "2026-07-09T17:49:43.862Z" } +sdist = { url = "https://files.pythonhosted.org/packages/96/59/9ea84cbeb8f09694564d3b0ee9dd59003551b308d47b61f251415df93982/google_genai-2.12.1.tar.gz", hash = "sha256:78c25217885d63dc430ca7c4526853512b164a25a93a8a0d0af5b85971aa1db0", size = 636710, upload-time = "2026-07-16T16:15:02.035Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/93/ef/d296c23390160a8b0b1dafb36dd3cb36a39ed40c81cd27e04e6233334186/google_genai-2.11.0-py3-none-any.whl", hash = "sha256:5bc8186100e1d34d691fbe0cba392b7e04e98d286ca952323a6672d054accf95", size = 984162, upload-time = "2026-07-09T17:49:42.15Z" }, + { url = "https://files.pythonhosted.org/packages/b6/b4/1369fb413fc2ba7f78acace5590b6e9990c52ab5d1d166aafaa1ae2c28c8/google_genai-2.12.1-py3-none-any.whl", hash = "sha256:686d5ec39bda345151d3ed1bac3915f01f49138b1ea519af2eb98f11cc55ebc4", size = 1023403, upload-time = "2026-07-16T16:14:59.79Z" }, ] [[package]] @@ -2750,7 +2750,7 @@ wheels = [ [package.optional-dependencies] litellm = [ - { name = "litellm", marker = "python_full_version < '3.14'" }, + { name = "litellm" }, ] [[package]] @@ -4708,7 +4708,7 @@ dev = [ requires-dist = [ { name = "aioboto3", marker = "extra == 'aioboto3'", specifier = ">=10.4.0" }, { name = "google-adk", marker = "extra == 'google-adk'", specifier = ">=2.2.0,<3" }, - { name = "google-genai", marker = "extra == 'google-genai'", specifier = ">=2.10.0,<3.0.0" }, + { name = "google-genai", marker = "extra == 'google-genai'", specifier = ">=2.12.0,<3.0.0" }, { name = "grpcio", marker = "extra == 'grpc'", specifier = ">=1.48.2,<2" }, { name = "langgraph", marker = "extra == 'langgraph'", specifier = ">=1.1.0" }, { name = "langsmith", marker = "extra == 'langsmith'", specifier = ">=0.7.34,<0.9" },