Uh oh!
There was an error while loading. Please reload this page.
Add pre-commit hook to prevent test-only imports in production source - #61713
Merged
shahar1 merged 1 commit intoFeb 10, 2026
Merged
Conversation
shahar1
requested review from
amoghrajesh, ashb, bugraoz93, gopidesupavan, jason810496, jscheffl, kaxil and potiuk
as code ownersFebruary 10, 2026 08:47
shahar1
marked this pull request as draft
February 10, 2026 09:08
shahar1force-pushed
the
prevent-tests-common-runtime-imports
branch
from
February 10, 2026 09:13
68ae9df to
d6b639cCompareshahar1
commented
Feb 10, 2026
ContributorAuthor
Yeah, just figured that I've missed it :) |
shahar1force-pushed
the
prevent-tests-common-runtime-imports
branch
2 times, most recently
from
February 10, 2026 09:34
60286cc to
3fec785Compareshahar1
marked this pull request as ready for review
February 10, 2026 09:38
shahar1force-pushed
the
prevent-tests-common-runtime-imports
branch
2 times, most recently
from
February 10, 2026 10:40
081aeca to
aa5a9d8Compare1 task
shahar1
marked this pull request as draft
February 10, 2026 11:26
This was referenced Feb 10, 2026
shahar1force-pushed
the
prevent-tests-common-runtime-imports
branch
from
February 10, 2026 11:44
aa5a9d8 to
816730dCompareshahar1force-pushed
the
prevent-tests-common-runtime-imports
branch
from
February 10, 2026 11:48
816730d to
4580241Compareshahar1
marked this pull request as ready for review
February 10, 2026 11:53
shahar1
commented
Feb 10, 2026
Uh oh!
There was an error while loading. Please reload this page.
jason810496
approved these changes
Feb 10, 2026
Uh oh!
There was an error while loading. Please reload this page.
Contributor
Backport failed to create: v3-1-test. View the failure log Run details
You can attempt to backport this manually by running: cherry_picker 6983599 v3-1-testThis should apply the commit to the v3-1-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
jscheffl
commented
Feb 10, 2026
Contributor
Cool! |
Alok-kumar-priyadarshi pushed a commit
to Alok-kumar-priyadarshi/airflow
that referenced
this pull request
Feb 11, 2026
Ratasa143 pushed a commit
to Ratasa143/airflow
that referenced
this pull request
Feb 15, 2026
choo121600 pushed a commit
to choo121600/airflow
that referenced
this pull request
Feb 22, 2026
AkshayArali pushed a commit
to AkshayArali/airflow_630
that referenced
this pull request
Feb 27, 2026
AkshayArali pushed a commit
to AkshayArali/airflow_630
that referenced
this pull request
Feb 27, 2026
Subham-KRLX pushed a commit
to Subham-KRLX/airflow
that referenced
this pull request
Mar 4, 2026
dominikhei pushed a commit
to dominikhei/airflow
that referenced
this pull request
Mar 11, 2026
Ankurdeewan pushed a commit
to Ankurdeewan/airflow
that referenced
this pull request
Mar 15, 2026
radhwene pushed a commit
to radhwene/airflow
that referenced
this pull request
Mar 21, 2026
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 freeto 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.
related: #60662
Adds a pre-commit hook that prevents test-only module imports from leaking into production source code (
*/src/). This addresses the class of bugs demonstrated by #61673, where atests_commonimport in the kubernetes provider caused aModuleNotFoundErrorat runtime.The hook detects two categories of forbidden imports:
tests_common.*— theapache-airflow-devel-commonpackage is dev-only.*.tests.*/tests.*— any import whose module path contains a.tests.component (e.g.from providers.cncf.kubernetes.tests.foo import bar). Test directories are not shipped in package wheels.Note (S.E.): the latter should be a relatively low risk because of how the current namespaces work. It could be somewhat helpful in case you messed up the imports while working locally, but such cases could be indicated quickly. I could remove if it's an overkill, the
tests_commonuse case is more prone.Strictness (see comment on the PR regarding necessity):
All imports from these modules are forbidden, including those guarded by
if TYPE_CHECKING:.This PR also fixes an existing violation in
BashOperator(standard provider) by movingArgNotSetcompatibility logic toversion_compat.py.The hook is AST-based (similar to
check_airflow_imports_in_shared.py) and runs on allsrc/files.Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot following the guidelines