Skip to content

Fix __getattr__ in helpers.py throwing AttributeError for dotted module paths - #71199

Open
KushagraB424 wants to merge 1 commit into
apache:mainfrom
KushagraB424:fix-getattr-dotted-imports
Open

Fix __getattr__ in helpers.py throwing AttributeError for dotted module paths#71199
KushagraB424 wants to merge 1 commit into
apache:mainfrom
KushagraB424:fix-getattr-dotted-imports

Conversation

@KushagraB424

Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug in airflow.utils.helpers.__getattr__ where the dynamic loading of deprecated functions (like render_template_as_native) was failing for dotted module paths (e.g. airflow.sdk.definitions.context).

When passing a dotted path to __import__ without the fromlist argument, it incorrectly returned the root package airflow instead of the target leaf module. This caused an AttributeError when the code subsequently tried to getattr the deprecated function directly on the root airflow module.

The fix replaces __import__(modpath) with importlib.import_module(modpath), which correctly returns the leaf module, allowing the compatibility shim and DeprecationWarning to function as intended.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Antigravity IDE following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

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.

Bug: __getattr__ in airflow.utils.helpers raises AttributeError for deprecated dotted imports

1 participant