From aeb18767cc6de2cea1a64d477850ffa6ab1038d4 Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Thu, 18 Dec 2025 17:25:54 -0800 Subject: [PATCH 1/2] Add backward compatibility for dynamic handler signatures --- temporalio/workflow.py | 6 +++++- tests/test_workflow.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/temporalio/workflow.py b/temporalio/workflow.py index e561a45ad..47495da03 100644 --- a/temporalio/workflow.py +++ b/temporalio/workflow.py @@ -26,6 +26,7 @@ from enum import Enum, Flag, IntEnum, auto from functools import partial from random import Random +import typing from typing import ( TYPE_CHECKING, Any, @@ -1919,7 +1920,10 @@ def _assert_dynamic_handler_args( not arg_types or len(arg_types) != 2 or arg_types[0] != str - or arg_types[1] != Sequence[temporalio.common.RawValue] + or ( + arg_types[1] != Sequence[temporalio.common.RawValue] + and arg_types[1] != typing.Sequence[temporalio.common.RawValue] + ) ): raise RuntimeError( "Dynamic handler must have 3 arguments: self, str, and Sequence[temporalio.common.RawValue]" diff --git a/tests/test_workflow.py b/tests/test_workflow.py index becb0d111..67dd4ba29 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -1,6 +1,7 @@ import inspect import itertools from collections.abc import Callable, Sequence +import typing from typing import Any, Set, Type, get_type_hints import pytest @@ -70,6 +71,27 @@ def update3(self, name: str, args: Sequence[RawValue]): pass +@workflow.defn() +class GoodDefnDeprecatedTypes(GoodDefnBase): + # Just having the definition here is enough to confirm the signatures + # do not trigger a RuntimeError + @workflow.run + async def run(self, name: str) -> str: + raise NotImplementedError + + @workflow.signal(dynamic=True) + def signal(self, name: str, args: typing.Sequence[RawValue]): + pass + + @workflow.query(dynamic=True) + def query(self, name: str, args: typing.Sequence[RawValue]): + pass + + @workflow.update(dynamic=True) + def update(self, name: str, args: typing.Sequence[RawValue]): + pass + + def test_workflow_defn_good(): # Although the API is internal, we want to check the literal definition just # in case From 5e6877a44ab74004f907610acf5e800afcf48ea7 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Thu, 18 Dec 2025 20:52:47 -0500 Subject: [PATCH 2/2] Linting --- temporalio/workflow.py | 2 +- tests/test_workflow.py | 2 +- uv.lock | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/temporalio/workflow.py b/temporalio/workflow.py index 47495da03..72e42e2fb 100644 --- a/temporalio/workflow.py +++ b/temporalio/workflow.py @@ -7,6 +7,7 @@ import inspect import logging import threading +import typing import uuid import warnings from abc import ABC, abstractmethod @@ -26,7 +27,6 @@ from enum import Enum, Flag, IntEnum, auto from functools import partial from random import Random -import typing from typing import ( TYPE_CHECKING, Any, diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 67dd4ba29..f46775975 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -1,7 +1,7 @@ import inspect import itertools -from collections.abc import Callable, Sequence import typing +from collections.abc import Callable, Sequence from typing import Any, Set, Type, get_type_hints import pytest diff --git a/uv.lock b/uv.lock index 92edd6f73..76ce83f28 100644 --- a/uv.lock +++ b/uv.lock @@ -2976,7 +2976,7 @@ requires-dist = [ { name = "grpcio", marker = "extra == 'grpc'", specifier = ">=1.48.2,<2" }, { name = "mcp", marker = "extra == 'openai-agents'", specifier = ">=1.9.4,<2" }, { name = "nexus-rpc", specifier = "==1.3.0" }, - { name = "openai-agents", marker = "extra == 'openai-agents'", specifier = ">=0.6.3,<0.7" }, + { name = "openai-agents", marker = "extra == 'openai-agents'", specifier = ">=0.3,<0.7" }, { name = "opentelemetry-api", marker = "extra == 'opentelemetry'", specifier = ">=1.11.1,<2" }, { name = "opentelemetry-sdk", marker = "extra == 'opentelemetry'", specifier = ">=1.11.1,<2" }, { name = "protobuf", specifier = ">=3.20,<7.0.0" }, @@ -2996,8 +2996,8 @@ dev = [ { name = "maturin", specifier = ">=1.8.2" }, { name = "mypy", specifier = "==1.18.2" }, { name = "mypy-protobuf", specifier = ">=3.3.0,<4" }, - { name = "openai-agents", marker = "python_full_version >= '3.14'", specifier = ">=0.6.3,<0.7" }, - { name = "openai-agents", extras = ["litellm"], marker = "python_full_version < '3.14'", specifier = ">=0.6.3,<0.7" }, + { name = "openai-agents", marker = "python_full_version >= '3.14'", specifier = ">=0.3,<0.7" }, + { name = "openai-agents", extras = ["litellm"], marker = "python_full_version < '3.14'", specifier = ">=0.3,<0.7" }, { name = "psutil", specifier = ">=5.9.3,<6" }, { name = "pydocstyle", specifier = ">=6.3.0,<7" }, { name = "pydoctor", specifier = ">=25.10.1,<26" },