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
22 changes: 22 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/airflow/AIR311_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
expand_alias_to_datasets,
)
from airflow.datasets.metadata import Metadata
from airflow.decorators import dag, setup, task, task_group, teardown
from airflow.io.path import ObjectStoragePath
from airflow.io.storage import attach
from airflow.models import DAG as DAGFromModel
from airflow.models.baseoperator import chain, chain_linear, cross_downstream
from airflow.models.baseoperatorlink import BaseOperatorLink
from airflow.models.dag import DAG as DAGFromDag
from airflow.timetables.datasets import DatasetOrTimeSchedule
from airflow.utils.dag_parsing_context import get_parsing_context

# airflow
DatasetFromRoot()

# airflow.datasets
Expand All @@ -24,6 +30,20 @@
Metadata()
expand_alias_to_datasets()

# airflow.decorators
dag()
task()
task_group()
setup()
teardown()

# airflow.io
ObjectStoragePath()
attach()

# airflow.models
DAGFromModel()

# airflow.models.baseoperator
chain()
chain_linear()
Expand All @@ -32,6 +52,8 @@
# airflow.models.baseoperatolinker
BaseOperatorLink()

# airflow.models.dag
DAGFromDag()
# airflow.timetables.datasets
DatasetOrTimeSchedule()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
"expand_alias_to_datasets" => Replacement::Name("airflow.sdk.expand_alias_to_assets"),
_ => return,
},

// airflow.decorators
["airflow", "decorators", rest @ ("dag" | "task" | "task_group" | "setup" | "teardown")] => {
Replacement::SourceModuleMoved {
module: "airflow.sdk",
name: (*rest).to_string(),
}
}

// airflow.io
["airflow", "io", "path", "ObjectStoragePath"] => Replacement::SourceModuleMoved {
module: "airflow.sdk",
name: "ObjectStoragePath".to_string(),
},
["airflow", "io", "storage", "attach"] => Replacement::SourceModuleMoved {
module: "airflow.sdk.io",
name: "attach".to_string(),
},

// airflow.models.baseoperator
["airflow", "models", "baseoperator", rest] => match *rest {
"chain" | "chain_linear" | "cross_downstream" => Replacement::SourceModuleMoved {
Expand All @@ -221,6 +240,11 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
}
_ => return,
},
// airflow.model..DAG
["airflow", "models", .., "DAG"] => Replacement::SourceModuleMoved {
module: "airflow.sdk",
name: "DAG".to_string(),
},
// airflow.timetables
["airflow", "timetables", "datasets", "DatasetOrTimeSchedule"] => {
Replacement::Name("airflow.timetables.assets.AssetOrTimeSchedule")
Expand Down
Loading
Loading