Skip to content

Fix deprecated imports resolution in airflow.utils.helpers - #71691

Merged
potiuk merged 1 commit into
apache:mainfrom
sgoel2be24-cyber:fix-helpers-deprecated-imports-submodule
Sep 10, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
sgoel2be24-cyber:fix-helpers-deprecated-imports-submodule

Conversation

@sgoel2be24-cyber

Copy link
Copy Markdown
Contributor

Description

In airflow.utils.helpers, __getattr__ resolves deprecated imports from __deprecated_imports by calling __import__(modpath). Because __import__ on dotted paths without a fromlist returns the top-level module (airflow) rather than the target submodule (e.g. airflow.sdk.definitions.context), attempting to import moved functions such as from airflow.utils.helpers import render_template_as_native raised ImportError.

This PR changes __getattr__ to use importlib.import_module(modpath) so that dotted submodules are imported correctly while preserving the deprecation warning.

Tests

  • Added test_deprecated_imports and test_deprecated_imports_unknown_attribute to airflow-core/tests/unit/utils/test_helpers.py.
  • All 28 tests in test_helpers.py pass.

@boring-cyborg

boring-cyborg Bot commented Aug 16, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@sgoel2be24-cyber
sgoel2be24-cyber force-pushed the fix-helpers-deprecated-imports-submodule branch from 665f6fb to 2f3bc05 Compare September 4, 2026 08:17
@sgoel2be24-cyber

Copy link
Copy Markdown
Contributor Author

Hi maintainers, I rebased this fix onto current main and reverified all 28 focused tests. Could someone review it when available?

@potiuk potiuk added this to the Airflow 3.3.2 milestone Sep 10, 2026
@potiuk
potiuk merged commit bb3e71d into apache:main Sep 10, 2026
155 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 10, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-3-test PR Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants