Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR301_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
from airflow.datasets import DatasetAliasEvent
from airflow.hooks.base_hook import BaseHook
from airflow.operators.subdag import SubDagOperator
from airflow.providers.mysql.datasets import mysql
from airflow.providers.postgres.datasets import postgres
from airflow.providers.trino.datasets import trino
from airflow.secrets.local_filesystem import LocalFilesystemBackend
from airflow.sensors.base_sensor_operator import BaseSensorOperator
from airflow.triggers.external_task import TaskStateTrigger
Expand Down Expand Up @@ -78,14 +75,6 @@
# airflow.operators.subdag.*
SubDagOperator()

# airflow.providers.mysql
mysql.sanitize_uri

# airflow.providers.postgres
postgres.sanitize_uri

# airflow.providers.trino
trino.sanitize_uri

# airflow.secrets
# get_connection
Expand Down Expand Up @@ -155,3 +144,18 @@
from airflow.operators.python import get_current_context

get_current_context()

# airflow.providers.mysql
from airflow.providers.mysql.datasets.mysql import sanitize_uri

sanitize_uri

# airflow.providers.postgres
from airflow.providers.postgres.datasets.postgres import sanitize_uri

sanitize_uri

# airflow.providers.trino
from airflow.providers.trino.datasets.trino import sanitize_uri

sanitize_uri
9 changes: 8 additions & 1 deletion crates/ruff_linter/src/rules/airflow/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ use ruff_python_semantic::SemanticModel;

#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) enum Replacement {
// There's no replacement or suggestion other than removal
None,
Name(&'static str),
// The attribute name of a class has been changed.
AttrName(&'static str),
// Additional information. Used when there's replacement but they're not direct mapping.
Message(&'static str),
// Symbols updated in Airflow 3 with replacement
// e.g., `airflow.datasets.Dataset` to `airflow.sdk.Asset`
AutoImport {
module: &'static str,
name: &'static str,
},
// Symbols updated in Airflow 3 with only module changed. Used when we want to match multiple names.
// e.g., `airflow.configuration.as_dict | get` to `airflow.configuration.conf.as_dict | get`
SourceModuleMoved {
module: &'static str,
name: String,
Expand Down
Loading
Loading