Skip to content

[Bug]: durable_execution(plugins=...) return type fails mypy with "Too few arguments" #921

Open

Description

@hln33

Expected Behavior

@durable_execution(plugins=[...]) applied to a def handler(event, context) passes mypy.

Actual Behavior

mypy 2.4.1 reports error: Too few arguments [call-arg] on the @durable_execution( line. Three call sites on main show it:

  • packages/aws-durable-execution-sdk-python-conformance-tests-telemetry/src/telemetry_1_success.py:42
  • packages/aws-durable-execution-sdk-python-conformance-tests-telemetry/src/telemetry_3_result_select.py:66
  • packages/aws-durable-execution-sdk-python-conformance-tests-otel/src/otel_5_child_context.py:30

Cause. durable_execution has one signature: execution.py:169-174. Its declared return type is Callable[[Any, LambdaContext], Any] for both call forms. When func is None, the function returns a decorator at runtime (execution.py:187-191). The declared type is still the two-argument handler. The decorator syntax then applies that two-argument type to the user function with one argument. So mypy reports Too few arguments.

CI does not catch it. .github/scripts/type-checks.sh runs mypy on five packages. It excludes the three conformance-test packages, which hold every plugins= call site.

Steps to Reproduce

mypy packages/aws-durable-execution-sdk-python-conformance-tests-telemetry/src/telemetry_3_result_select.py

SDK Version

main at 93751c46

Python Version

3.14

Is this a regression?

No

Last Working Version

No response

Additional Context

Proposed fix: two @overloads on durable_execution.

  1. func given positionally → returns Callable[[Any, LambdaContext], Any].
  2. func: None = None with keyword-only boto3_client and plugins → returns Callable[[Callable[[Any, DurableContext], Any]], Callable[[Any, LambdaContext], Any]].

Add a test under packages/aws-durable-execution-sdk-python/tests that uses both call forms, so types:check covers the decorator-factory form.

Raised by @ParidelPooya in the #916 review.

Activity

  1. pcbeingused333 commented on Nov 11, 2026

    @pcbeingused333

    Design note for CONTRIBUTING rule 3: the parameterized decorator form should pass mypy while preserving the existing bare-decorator form.
    The cause described above is still present on main (e436a33f): the factory call is annotated as a two-argument handler even though it returns a decorator.
    The options are to simplify the existing implementation, use a union return type, or describe the two call forms with overloads; the runtime already has the required two paths, and a union would leave both forms ambiguous to the type checker, so I propose the two overloads outlined in the issue, with no runtime changes and nothing removed.
    Validation would add a failing type-check case for @durable_execution(plugins=[]) alongside the bare @durable_execution form under the core package's tests/, which is already covered by types:check, and run the core unit tests without modifying any conformance-test package.
    If a maintainer agrees with this design, I can prepare the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions