diff --git a/temporalio/workflow.py b/temporalio/workflow.py index e561a45ad..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 @@ -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..f46775975 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -1,5 +1,6 @@ import inspect import itertools +import typing from collections.abc import Callable, Sequence from typing import Any, Set, Type, get_type_hints @@ -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 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" },