Fix @task decorator to use identity check instead of truthiness#63788
Merged
eladkal merged 2 commits intoapache:mainfrom Mar 18, 2026
Merged
Fix @task decorator to use identity check instead of truthiness#63788eladkal merged 2 commits intoapache:mainfrom
eladkal merged 2 commits intoapache:mainfrom
Conversation
148c3f8 to
149ee6c
Compare
uranusjr
reviewed
Mar 18, 2026
uranusjr
approved these changes
Mar 18, 2026
Changed the serialized Dag test proxy so task is exposed via a property returning `factory.dag.task`, instead of binding `task = factory.dag.task` on the proxy class. The two fixes address the same Python 3.14 issue surface in serialized-DAG decorator tests: - The proxy used by `dag_maker` can leak proxy/binding behavior into `@dag.task`. - Python 3.14 is less forgiving when `inspect.signature()` and callable binding hit those proxy objects. - The truthiness check in `task_decorator_factory()` made that worse by evaluating objects that only needed an identity check. Together, the effect is: - `@dag.task` gets the real task decorator from the underlying Dag, not a proxy-bound callable. - `task_decorator_factory()` no longer triggers proxy resolution via boolean evaluation.
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
1fff339 to
4960bee
Compare
eladkal
approved these changes
Mar 18, 2026
fat-catTW
pushed a commit
to fat-catTW/airflow
that referenced
this pull request
Mar 22, 2026
…he#63788) * Avoid invoking truthiness on the `task` callable Changed the serialized Dag test proxy so task is exposed via a property returning `factory.dag.task`, instead of binding `task = factory.dag.task` on the proxy class. The two fixes address the same Python 3.14 issue surface in serialized-DAG decorator tests: - The proxy used by `dag_maker` can leak proxy/binding behavior into `@dag.task`. - Python 3.14 is less forgiving when `inspect.signature()` and callable binding hit those proxy objects. - The truthiness check in `task_decorator_factory()` made that worse by evaluating objects that only needed an identity check. Together, the effect is: - `@dag.task` gets the real task decorator from the underlying Dag, not a proxy-bound callable. - `task_decorator_factory()` no longer triggers proxy resolution via boolean evaluation. * Update task-sdk/src/airflow/sdk/bases/decorator.py Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> --------- Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
techcodie
pushed a commit
to techcodie/airflow
that referenced
this pull request
Mar 23, 2026
…he#63788) * Avoid invoking truthiness on the `task` callable Changed the serialized Dag test proxy so task is exposed via a property returning `factory.dag.task`, instead of binding `task = factory.dag.task` on the proxy class. The two fixes address the same Python 3.14 issue surface in serialized-DAG decorator tests: - The proxy used by `dag_maker` can leak proxy/binding behavior into `@dag.task`. - Python 3.14 is less forgiving when `inspect.signature()` and callable binding hit those proxy objects. - The truthiness check in `task_decorator_factory()` made that worse by evaluating objects that only needed an identity check. Together, the effect is: - `@dag.task` gets the real task decorator from the underlying Dag, not a proxy-bound callable. - `task_decorator_factory()` no longer triggers proxy resolution via boolean evaluation. * Update task-sdk/src/airflow/sdk/bases/decorator.py Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> --------- Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
if python_callable:toif python_callable is not None:intask_decorator_factory()to avoid triggering__bool__on callable objects.taskattribute on the serialized DAG test proxy from a class-level binding to a@property, preventing proxy leakage into the decorator callable.__bool__.xfailmarker fromtest_infer_multiple_outputs_forward_annotation(now passes).Details
task_decorator_factory()usedif python_callable:which invokes__bool__on the argument. This is incorrect — a callable that happens to be falsey (e.g.,__bool__returnsFalse) would incorrectly take the "no callable provided" path. The fix usesis not Nonefor a proper identity check and consolidates the error handling.The test proxy in
dag_makerboundtask = factory.dag.taskas a class attribute, which caused proxy binding behavior to leak into the decorator when accessed via@dag.task. Converting to a@propertyensures the realtaskdecorator is returned without proxy interference.related: #63520
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.6 following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.