[`airflow`] Extend `AIR301` rule (#17598)

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Add "airflow.operators.python.get_current_context" →
"airflow.sdk.get_current_context" rule

## Test Plan

<!-- How was it tested? -->

the test fixture has been updated accordingly
This commit is contained in:
Wei Lee 2025-04-26 01:49:32 +09:00 committed by GitHub
parent b6281a8805
commit aba21a5d47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View File

@ -150,3 +150,8 @@ has_access
# airflow.www.utils
get_sensitive_variables_fields
should_hide_value_for_key
# airflow.operators.python
from airflow.operators.python import get_current_context
get_current_context()

View File

@ -672,6 +672,10 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
["airflow", "operators", "subdag", ..] => {
Replacement::Message("The whole `airflow.subdag` module has been removed.")
}
["airflow", "operators", "python", "get_current_context"] => Replacement::AutoImport {
module: "airflow.sdk",
name: "get_current_context",
},
// airflow.secrets
["airflow", "secrets", "local_filesystem", "load_connections"] => Replacement::AutoImport {

View File

@ -433,5 +433,16 @@ AIR301_names.py:152:1: AIR301 `airflow.www.utils.should_hide_value_for_key` is r
151 | get_sensitive_variables_fields
152 | should_hide_value_for_key
| ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301
153 |
154 | # airflow.operators.python
|
= help: Use `airflow.utils.log.secrets_masker.should_hide_value_for_key` instead
AIR301_names.py:157:1: AIR301 `airflow.operators.python.get_current_context` is removed in Airflow 3.0
|
155 | from airflow.operators.python import get_current_context
156 |
157 | get_current_context()
| ^^^^^^^^^^^^^^^^^^^ AIR301
|
= help: Use `airflow.sdk.get_current_context` instead