This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new cbf4b9b8501 fix: suppress warning for TYPE_CHECKING-only forward 
references in TaskFlow (#63053)
cbf4b9b8501 is described below

commit cbf4b9b8501705b7433d0a4d0c1bf859735a745c
Author: Pradeep Kalluri <[email protected]>
AuthorDate: Tue Mar 10 19:27:58 2026 +0000

    fix: suppress warning for TYPE_CHECKING-only forward references in TaskFlow 
(#63053)
    
    Fixes #62945
---
 .../standard/tests/unit/standard/decorators/test_python.py   | 12 +-----------
 task-sdk/src/airflow/sdk/bases/decorator.py                  | 10 +++-------
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/providers/standard/tests/unit/standard/decorators/test_python.py 
b/providers/standard/tests/unit/standard/decorators/test_python.py
index d2aa38ec544..95c96ce7bed 100644
--- a/providers/standard/tests/unit/standard/decorators/test_python.py
+++ b/providers/standard/tests/unit/standard/decorators/test_python.py
@@ -195,17 +195,7 @@ class TestAirflowTaskDecorator(BasePythonTest):
             y: int,
         ) -> "UnresolveableName[int, int]": ...
 
-        with pytest.warns(UserWarning, match="Cannot infer 
multiple_outputs.*t3") as recwarn:
-            line = sys._getframe().f_lineno - 5 if PY38 else 
sys._getframe().f_lineno - 2
-
-        if PY311:
-            # extra line explaining the error location in Py311
-            line = line - 1
-
-        warn = recwarn[0]
-        assert warn.filename == __file__
-        assert warn.lineno == line
-
+        # No warning should be raised for TYPE_CHECKING-only forward references
         assert t3(5, 5).operator.multiple_outputs is False
 
     def test_infer_multiple_outputs_using_other_typing(self):
diff --git a/task-sdk/src/airflow/sdk/bases/decorator.py 
b/task-sdk/src/airflow/sdk/bases/decorator.py
index 53565c531a6..d76c0298278 100644
--- a/task-sdk/src/airflow/sdk/bases/decorator.py
+++ b/task-sdk/src/airflow/sdk/bases/decorator.py
@@ -20,7 +20,6 @@ import inspect
 import itertools
 import re
 import textwrap
-import warnings
 from collections.abc import Callable, Collection, Iterator, Mapping, Sequence
 from contextlib import suppress
 from functools import cached_property, partial, update_wrapper
@@ -448,12 +447,9 @@ class _TaskDecorator(ExpandableFactory, Generic[FParams, 
FReturn, OperatorSubcla
             fake.__annotations__ = {"return": 
self.function.__annotations__["return"]}
 
             return_type = typing_extensions.get_type_hints(fake, 
self.function.__globals__).get("return", Any)
-        except NameError as e:
-            warnings.warn(
-                f"Cannot infer multiple_outputs for TaskFlow function 
{self.function.__name__!r} with forward"
-                f" type references that are not imported. (Error was {e})",
-                stacklevel=4,
-            )
+        except NameError:
+            # Forward references using TYPE_CHECKING-only imports are valid 
Python patterns.
+            # We cannot infer multiple_outputs when the type is not available 
at runtime.
             return False
         except TypeError:  # Can't evaluate return type.
             return False

Reply via email to