Repository navigation
Detect Dag subclasses in the Dag version inflation check - #72861
Merged
Merged
Conversation
The check only recognized a Dag constructor when the callable resolved through a from-import of airflow's DAG or dag. A Dag built from a subclass, or reached through an aliased module import, produced no warnings at all — and because task detection keys off the same predicate, neither did any task inside its with-block. The Dag file is not imported yet when the check runs, so there is no object to test — only names and the file's own imports. The cost of leaning on names is an occasional false positive on something merely named like a Dag.
vatsrahul1001
approved these changes
Sep 10, 2026
amoghrajesh
approved these changes
Sep 10, 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.
|
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Sep 10, 2026
…pache#72861) The check only recognized a Dag constructor when the callable resolved through a from-import of airflow's DAG or dag. A Dag built from a subclass, or reached through an aliased module import, produced no warnings at all — and because task detection keys off the same predicate, neither did any task inside its with-block. The Dag file is not imported yet when the check runs, so there is no object to test — only names and the file's own imports. The cost of leaning on names is an occasional false positive on something merely named like a Dag. (cherry picked from commit 1e2ad80) Co-authored-by: Jed Cunningham <[email protected]>
vatsrahul1001
added a commit
that referenced
this pull request
Sep 11, 2026
…72861) (#72898) * [v3-3-test] Detect Dag subclasses in the Dag version inflation check (#72861) The check only recognized a Dag constructor when the callable resolved through a from-import of airflow's DAG or dag. A Dag built from a subclass, or reached through an aliased module import, produced no warnings at all — and because task detection keys off the same predicate, neither did any task inside its with-block. The Dag file is not imported yet when the check runs, so there is no object to test — only names and the file's own imports. The cost of leaning on names is an occasional false positive on something merely named like a Dag. (cherry picked from commit 1e2ad80) Co-authored-by: Jed Cunningham <[email protected]> * Add missing dedent import to fix the version inflation checker tests --------- Co-authored-by: Jed Cunningham <[email protected]> Co-authored-by: Rahul Vats <[email protected]> Co-authored-by: Rahul Vats <[email protected]>
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 Dag version inflation check only spotted a Dag constructor when the callable resolved
through a from-import of airflow's
DAGordag. A Dag built from a subclass, or reachedthrough an aliased module import, produced no warnings at all — and since task detection keys
off the same predicate, neither did any task inside its
withblock.Detection now uses the callable's name as well as the import table. The check runs before the
Dag file is imported, so there is no object to test — the name and the file's own imports are
the only evidence available.
Newly caught, both silent before:
Three consequences of the heuristic, worth a reviewer's attention:
A non-Dag named
*Dagassigned to a variable is treated as a Dag, so real warnings on lateruses of that variable are lost:
Tracking the assignment anyway would restore that warning, at the cost of the common path:
Both are a varying-valued call detected as a Dag constructor and assigned to a name, so
nothing downstream separates them — it is a choice of which one to get wrong. Assigning a Dag
and passing
dag=dagto its tasks is everyday Airflow; naming a non-Dag*Dagis not. Sotracking would trade a rare miss for a routine false positive, on the very case the check
exists to catch.
The suffix is case-sensitive, so
create_DAG()matches wherecreate_dag()does not. A namecannot tell a Dag subclass from a factory function.
At
errorlevel a false positive marks the Dag stale, so it stops scheduling rather thanmerely failing to parse. The default is
warning, so this is opt-in.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5)