Skip to content

[v3-3-test] Fix wtforms-mocking condition (#70811) - #70821

Merged
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-445549a-v3-3-test
Aug 3, 2026
Merged

[v3-3-test] Fix wtforms-mocking condition (#70811)#70821
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-445549a-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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

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>
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Jul 31, 2026
@pierrejeambrun
pierrejeambrun marked this pull request as ready for review July 31, 2026 14:37
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.3.1 milestone Aug 3, 2026
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Aug 3, 2026
@vatsrahul1001
vatsrahul1001 merged commit f0d61fa into v3-3-test Aug 3, 2026
121 of 127 checks passed
@vatsrahul1001
vatsrahul1001 deleted the backport-445549a-v3-3-test branch August 3, 2026 05:32
vatsrahul1001 pushed a commit that referenced this pull request Aug 5, 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants