Fix __getattr__ in helpers.py throwing AttributeError for dotted module paths - #71199
Open
KushagraB424 wants to merge 1 commit into
Open
Fix __getattr__ in helpers.py throwing AttributeError for dotted module paths#71199KushagraB424 wants to merge 1 commit into
KushagraB424 wants to merge 1 commit into
Conversation
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.
Description
This PR fixes a bug in
airflow.utils.helpers.__getattr__where the dynamic loading of deprecated functions (likerender_template_as_native) was failing for dotted module paths (e.g.airflow.sdk.definitions.context).When passing a dotted path to
__import__without thefromlistargument, it incorrectly returned the root packageairflowinstead of the target leaf module. This caused anAttributeErrorwhen the code subsequently tried togetattrthe deprecated function directly on the rootairflowmodule.The fix replaces
__import__(modpath)withimportlib.import_module(modpath), which correctly returns the leaf module, allowing the compatibility shim andDeprecationWarningto function as intended.Was generative AI tooling used to co-author this PR?
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