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

Đang mở
#921 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
aws, python

Hướng nghiên cứu

Start with execution.py in packages/aws-durable-execution-sdk-python/src, where durable_execution is declared with one signature and its return type is Callable[[Any, LambdaContext], Any] for both call forms. Reproduce by running mypy on telemetry_3_result_select.py in the conformance-tests-telemetry package. Done when the two-overload form type-checks for both @durable_execution and @durable_execution(plugins=...), and a test under the SDK's tests directory covers the decorator-factory form.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
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.

Ngôn ngữ chính
Python
Star
58
Fork
32
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
80

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws/aws-durable-execution-sdk-python

Tất cả issue của aws/aws-durable-execution-sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.