From 7ab18f6d8b77bd745b28f8701f6177924ef46f44 Mon Sep 17 00:00:00 2001 From: SRI VILLIAM SAI Date: Sun, 15 Nov 2026 11:49:07 +0530 Subject: [PATCH 1/2] test(sdk): test parameterized durable_execution typing Adds test reproducing issue #921 with durable_execution typing. --- .../tests/execution_test.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/aws-durable-execution-sdk-python/tests/execution_test.py b/packages/aws-durable-execution-sdk-python/tests/execution_test.py index 10258bad6..1dfbae474 100644 --- a/packages/aws-durable-execution-sdk-python/tests/execution_test.py +++ b/packages/aws-durable-execution-sdk-python/tests/execution_test.py @@ -4617,6 +4617,33 @@ def test_handler(event: Any, context: DurableContext) -> dict: return decorator(test_handler), test_handler +@durable_execution +def _bare_decorator_typed_handler( + event: Any, context: DurableContext +) -> dict[str, Any]: + """Verify bare decorator form type checks properly.""" + return {"result": "success"} + + +@durable_execution(plugins=[]) +def _parameterized_decorator_typed_handler( + event: Any, context: DurableContext +) -> dict[str, Any]: + """Verify parameterized decorator form type checks properly.""" + return {"result": "success"} + + +@pytest.mark.parametrize( + "handler", + [_bare_decorator_typed_handler, _parameterized_decorator_typed_handler], + ids=["bare", "parameterized"], +) +def test_typed_decorated_handler_signature(handler) -> None: + """Verify decorated handlers have the expected (event, context) signature.""" + signature = inspect.signature(handler) + assert list(signature.parameters) == ["event", "context"] + + @pytest.mark.parametrize( "build_handler", [_bare_decorated_handler, _plugin_decorated_handler], From 9083a0e36bbe5b68ed25bbbeac8f67ee9a56618b Mon Sep 17 00:00:00 2001 From: SRI VILLIAM SAI Date: Sun, 15 Nov 2026 11:51:48 +0530 Subject: [PATCH 2/2] fix(sdk): add overloads for durable_execution (#921) Add typing overloads for bare and parameterized decorator forms. --- .../execution.py | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py b/packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py index 59f64f00b..c5d4e3403 100644 --- a/packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py +++ b/packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/execution.py @@ -7,7 +7,7 @@ import logging from concurrent.futures import Future, ThreadPoolExecutor, wait from dataclasses import dataclass, field -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, overload from aws_durable_execution_sdk_python.context import DurableContext from aws_durable_execution_sdk_python.exceptions import ( @@ -166,12 +166,39 @@ def from_durable_execution_invocation_input( # endregion Invocation models +@overload +def durable_execution( + func: Callable[[Any, DurableContext], Any], + *, + boto3_client: Boto3LambdaClient | None = None, + plugins: list[DurableInstrumentationPluginFactory] | None = None, +) -> Callable[[Any, LambdaContext], Any]: ... + + +@overload +def durable_execution( + func: None = None, + *, + boto3_client: Boto3LambdaClient | None = None, + plugins: list[DurableInstrumentationPluginFactory] | None = None, +) -> Callable[ + [Callable[[Any, DurableContext], Any]], + Callable[[Any, LambdaContext], Any], +]: ... + + def durable_execution( func: Callable[[Any, DurableContext], Any] | None = None, *, boto3_client: Boto3LambdaClient | None = None, plugins: list[DurableInstrumentationPluginFactory] | None = None, -) -> Callable[[Any, LambdaContext], Any]: +) -> ( + Callable[[Any, LambdaContext], Any] + | Callable[ + [Callable[[Any, DurableContext], Any]], + Callable[[Any, LambdaContext], Any], + ] +): """ Decorator to create a durable execution handler.