Fix wtforms-mocking condition - #70811
Merged
Merged
Conversation
The previous code
"wtforms.StringField" not in sys.modules
always evaluates to True because StringField is not a module, and is
never present in sys.modules even if wtforms IS installed and imported.
Judging from surrounding code, I think the original intention is to only
patch if wtforms is not installed (and thuse a MagicMock was injected in
the previous block). This changes the check to reflect my assumed
intention.
I also tightened the custom ModuleNotFoundError a bit to carry more
useful information.
uranusjr
requested review from
bugraoz93,
ephraimbuddy,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
July 31, 2026 07:01
eladkal
approved these changes
Jul 31, 2026
Contributor
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Jul 31, 2026
The previous code
"wtforms.StringField" not in sys.modules
always evaluates to True because StringField is not a module, and is
never present in sys.modules even if wtforms IS installed and imported.
Judging from surrounding code, I think the original intention is to only
patch if wtforms is not installed (and thuse a MagicMock was injected in
the previous block). This changes the check to reflect my assumed
intention.
I also tightened the custom ModuleNotFoundError a bit to carry more
useful information.
(cherry picked from commit 445549a)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Jul 31, 2026
The previous code
"wtforms.StringField" not in sys.modules
always evaluates to True because StringField is not a module, and is
never present in sys.modules even if wtforms IS installed and imported.
Judging from surrounding code, I think the original intention is to only
patch if wtforms is not installed (and thuse a MagicMock was injected in
the previous block). This changes the check to reflect my assumed
intention.
I also tightened the custom ModuleNotFoundError a bit to carry more
useful information.
(cherry picked from commit 445549a)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Aug 3, 2026
The previous code
"wtforms.StringField" not in sys.modules
always evaluates to True because StringField is not a module, and is
never present in sys.modules even if wtforms IS installed and imported.
Judging from surrounding code, I think the original intention is to only
patch if wtforms is not installed (and thuse a MagicMock was injected in
the previous block). This changes the check to reflect my assumed
intention.
I also tightened the custom ModuleNotFoundError a bit to carry more
useful information.
(cherry picked from commit 445549a)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
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.
The previous code (introduced in #63986)
always evaluates to True because StringField is not a module, and is never present in sys.modules even if wtforms IS installed and imported.
Judging from surrounding code, I think the original intention is to only patch if wtforms is not installed (and thuse a MagicMock was injected in the previous block). This changes the check to reflect my assumed intention.
I also tightened the custom ModuleNotFoundError a bit to carry more useful information.
cc @Subham-KRLX