Clarify task decorator argument errors (#49875) - #69157
Conversation
shahar1
left a comment
There was a problem hiding this comment.
@deepujain please note that you (or your operator) should include AI attribution in the PR as we state in the AI guidelines.
This PR, as well as others, are blocked from being merged until this is corrected.
Please be warned that creating additional PRs except for the 10 you've already created (listed below) without addressing the above might cause in a permanent block from Apache organization on GitHub.
List of PRs:
2c14d36 to
8ac47bd
Compare
|
Rebased this branch onto current Drafted-by: OpenAI Codex (no human review before posting) |
8ac47bd to
5fdd4b4
Compare
|
The three provider compatibility jobs failed while importing an incompatible Drafted-by: OpenAI Codex (no human review before posting) |
5fdd4b4 to
c9485a7
Compare
|
Rebased onto current Drafted-by: OpenAI Codex (no human review before posting) |
Title: Clarify task decorator argument errors (#49875)
Summary
Calling a decorated task object like a regular function can raise a bare
TypeError: too many positional arguments, which makes the reported name-shadowing failure hard to diagnose. This keeps the existing binding validation but adds a targeted hint only when the binding failure already happened for extra positional arguments.Changes
task-sdk/src/airflow/sdk/bases/decorator.py-- wrap signature binding errors and append an accidental decorated-task-call hint only for extra positional arguments.task-sdk/tests/task_sdk/bases/test_decorator.py-- add regression coverage for the accidental call case and verify missing required arguments do not receive the hint.airflow-core/newsfragments/69157.bugfix.rst-- add a bugfix release note for the user-facing error-message improvement.Evidence it works
Test plan
uvx --from uv==0.11.21 uv run --project task-sdk ruff format --check task-sdk/src/airflow/sdk/bases/decorator.py task-sdk/tests/task_sdk/bases/test_decorator.pyuvx --from uv==0.11.21 uv run --project task-sdk ruff check task-sdk/src/airflow/sdk/bases/decorator.py task-sdk/tests/task_sdk/bases/test_decorator.pyuvx --from uv==0.11.21 uv run --project task-sdk pytest task-sdk/tests/task_sdk/bases/test_decorator.py::TestDefaultFillingLogic::test_bind_validation_hints_for_accidental_task_decorator_call task-sdk/tests/task_sdk/bases/test_decorator.py::TestDefaultFillingLogic::test_bind_validation_missing_required_args_has_no_accidental_call_hint -xvsWas generative AI tooling used to co-author this PR?
Generated-by: OpenAI Codex following the guidelines
Fixes #49875