Repository navigation
KN-5: no-alias-sort-keys rule from apache/airflow#75025 with real-cod… - #7
Merged
Merged
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.
Summary
Adds the first guard rule,
no-alias-sort-keys, encoding the decision fromapache/airflow#75025:
get_dags()must not sort bystate/start_date,and the rejected fix of aliasing them onto
DagRun.state/DagRun.start_dateis also blocked.The rule flags either form inside a
SortParam(...)call. The outerinsideuses
stopBy: end; without it the rule silently matches nothing (verified:removing it drops violating.py from 2 matches to 0). Direct-parent checks
use
stopBy: neighbordeliberately.Fixtures come from the real PR (base 935bac04f06a, head ac13d1d9f9e6),
trimmed to excerpts with Apache-2.0 headers.
rejected_alias.pyis the oneexception: constructed from the alternative described in review, and labelled
MODIFIED, not Airflow code. Fixtures are excluded from ufmt and pyright so they
stay verbatim.
This rule is intentionally specific. It's the hand-written answer key the Muse
Spark compiler will be measured against.
Test Plan
Red run first:
ast-grep scan --rule knack/guard/rules/no-alias-sort-keys.yml --json→ Error: Cannot read rule, exit 6; all rule tests failedGreen:
Green:
pytest→ 45 passed (7 rule tests + 38 existing)ufmt check knack tests→ cleanpyright→ 0 errorsTicket
KN-5