[airflow] Refine and add rules to capture deprecated arguments and a decorator (AIR301)#23170
Merged
ntBre merged 3 commits intoastral-sh:mainfrom Feb 10, 2026
Merged
Conversation
|
b3096f9 to
67ac898
Compare
67ac898 to
5f5d27e
Compare
2 tasks
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
Related: apache/airflow#41641 (comment)
The PR add/refine rules for the following function signature change in Airflow 3.0.
Variable.get()According to the following documents:
2.11.0: https://airflow.apache.org/docs/apache-airflow/2.11.0/core-concepts/variables.html
3.0.6: https://airflow.apache.org/docs/apache-airflow/3.0.6/core-concepts/variables.html
More context: apache/airflow#41641 (comment)
In Airflow 2.x, the class method
getofVariablefromairflow.modelshas akeywordargument nameddefault_var.In AIR311, there is a rule to detect the migration from
airflow.models.Variabletoairflow.sdk.Variable. However, in Airflow 3, the change of the keyword argument fromdefault_vartodefaultis not yet captured. The syntax in Airflow 3 is as follow:Therefore, a new rule is added in AIR303 to detect the use of
default_varwhenVariableis imported fromairflow.sdk. The rule suggests a fix to use thedefaultas argument name instead ofdefault_var.provide_contextis deprecated from python operatorsSecond, the
provide_contextparameter is deprecated in Airflow 2 for python operators. It is still a valid syntax to set it in Airflow 2, but it is removed in Airflow 3. A rule is added to detect the presence of the keyword argument inPythonOperatorandPythonVirtualenvOperator. The constructor call only accept keyword-only arguments. The rule will raise a warning message when this keyword argument is passed.Deprecated value for
trigger_ruleargument in TaskFlow API and Airflow operatorsThe current rule implemented in
check_nameonly catchesTriggerRule.NONE_FAILED_OR_SKIPPEDvia qualified name resolution. However, the argument is usually passed in the following way. (Here,PythonOperatoris an example, all Airflow operators can be configured with atrigger_rule, since they inherit fromBaseOperator).Therefore, the existing rule is removed and re-implemented. There are two cases will be captured. A string value is passed into the
@taskdecorator or the operator, the rule will fixnone_failed_or_skippedtonone_failed_min_one_successandTriggerRule.NONE_FAILED_OR_SKIPPEDtoTriggerRule.NONE_FAILED_MIN_ONE_SUCCESSDeprecated
apply_defaultsdecoratorSimilar to the above case, this decorator is also checked via qualified name resolution. The decorator is used in the following way. The existing rule is also removed, and re-implemented to capture the below use case, and suggest a fix to remove this decorator entirely.
Test Plan
New test cases have been added to
AIR301_args.pyandAIR301_decorator.py. The test snapshots are updated.