This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new 7369869af85 [v3-3-test] Fix deprecated imports resolution in
airflow.utils.helpers (#71691) (#72868)
7369869af85 is described below
commit 7369869af854d779f630d9b6b0dcb57bcb0cac86
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Sep 10 10:15:59 2026 +0200
[v3-3-test] Fix deprecated imports resolution in airflow.utils.helpers
(#71691) (#72868)
(cherry picked from commit bb3e71da4669dc0323eda3651dac18a9eed57275)
Co-authored-by: Shikhar Goel <[email protected]>
Co-authored-by: Shikhar Goel
<[email protected]>
Co-authored-by: Rahul Vats <[email protected]>
---
airflow-core/src/airflow/utils/helpers.py | 4 +++-
airflow-core/tests/unit/utils/test_helpers.py | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/airflow-core/src/airflow/utils/helpers.py
b/airflow-core/src/airflow/utils/helpers.py
index 73265463edc..298f2ffb4b7 100644
--- a/airflow-core/src/airflow/utils/helpers.py
+++ b/airflow-core/src/airflow/utils/helpers.py
@@ -313,6 +313,7 @@ def __getattr__(name: str):
except KeyError:
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
from None
+ import importlib
import warnings
warnings.warn(
@@ -320,4 +321,5 @@ def __getattr__(name: str):
DeprecationWarning,
stacklevel=2,
)
- return getattr(__import__(modpath), name)
+ mod = importlib.import_module(modpath)
+ return getattr(mod, name)
diff --git a/airflow-core/tests/unit/utils/test_helpers.py
b/airflow-core/tests/unit/utils/test_helpers.py
index ab82f820475..f9fa7535905 100644
--- a/airflow-core/tests/unit/utils/test_helpers.py
+++ b/airflow-core/tests/unit/utils/test_helpers.py
@@ -242,6 +242,29 @@ class TestHelpers:
d2 = {"a": None, "b": "", "c": d1, "d": l1, "e": [None, "", 0, d1, l1,
[""]], "f": {}, "g": [""]}
assert prune_dict(d2, mode=mode) == expected
+ @pytest.mark.parametrize(
+ ("func_name", "target_module"),
+ [
+ ("render_template_as_native", "airflow.sdk.definitions.context"),
+ ("render_template_to_string", "airflow.sdk.definitions.context"),
+ ("prevent_duplicates", "airflow.sdk.definitions.mappedoperator"),
+ ],
+ )
+ def test_deprecated_imports(self, func_name, target_module):
+ import importlib
+
+ with pytest.deprecated_call():
+ imported_func = getattr(helpers, func_name)
+ target_mod = importlib.import_module(target_module)
+ expected_func = getattr(target_mod, func_name)
+ assert imported_func is expected_func
+
+ def test_deprecated_imports_unknown_attribute(self):
+ with pytest.raises(
+ AttributeError, match="module 'airflow.utils.helpers' has no
attribute 'non_existent_func'"
+ ):
+ _ = helpers.non_existent_func
+
class MockJobRunner(BaseJobRunner):
job_type = "MockJob"