[`airflow`] Add unsafe fix for module moved cases (`AIR311`) (#18366)

<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

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

Follow up on https://github.com/astral-sh/ruff/pull/18093 and apply it
to AIR311

---

Rules fixed
* `airflow.models.datasets.expand_alias_to_datasets` →
`airflow.models.asset.expand_alias_to_assets`
* `airflow.models.baseoperatorlink.BaseOperatorLink` →
`airflow.sdk.BaseOperatorLink`


## Test Plan

<!-- How was it tested? -->
The existing test fixtures have been updated
This commit is contained in:
Wei Lee 2025-05-30 21:27:14 +08:00 committed by GitHub
parent b5b6b657cc
commit 0c29e258c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 502 additions and 299 deletions

View File

@ -9,19 +9,12 @@ from airflow.datasets import (
expand_alias_to_datasets, expand_alias_to_datasets,
) )
from airflow.datasets.metadata import Metadata from airflow.datasets.metadata import Metadata
from airflow.decorators import dag, setup, task, task_group, teardown from airflow.decorators import (
from airflow.io.path import ObjectStoragePath dag,
from airflow.io.storage import attach setup,
from airflow.models import DAG as DAGFromModel task,
from airflow.models import ( task_group,
Connection,
Variable,
) )
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 # airflow
DatasetFromRoot() DatasetFromRoot()
@ -39,9 +32,22 @@ dag()
task() task()
task_group() task_group()
setup() setup()
from airflow.decorators import teardown
from airflow.io.path import ObjectStoragePath
from airflow.io.storage import attach
from airflow.models import DAG as DAGFromModel
from airflow.models import (
Connection,
Variable,
)
from airflow.models.baseoperator import chain, chain_linear, cross_downstream
from airflow.models.baseoperatorlink import BaseOperatorLink
from airflow.models.dag import DAG as DAGFromDag
# airflow.decorators
teardown() teardown()
# airflow.io # # airflow.io
ObjectStoragePath() ObjectStoragePath()
attach() attach()
@ -60,6 +66,9 @@ BaseOperatorLink()
# airflow.models.dag # airflow.models.dag
DAGFromDag() DAGFromDag()
from airflow.timetables.datasets import DatasetOrTimeSchedule
from airflow.utils.dag_parsing_context import get_parsing_context
# airflow.timetables.datasets # airflow.timetables.datasets
DatasetOrTimeSchedule() DatasetOrTimeSchedule()

View File

@ -1,7 +1,7 @@
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::importer::ImportRequest; use crate::rules::airflow::helpers::{Replacement, is_airflow_builtin_or_provider};
use crate::rules::airflow::helpers::{ use crate::rules::airflow::helpers::{
Replacement, is_airflow_builtin_or_provider, is_guarded_by_try_except, generate_import_edit, generate_remove_and_runtime_import_edit, is_guarded_by_try_except,
}; };
use crate::{Edit, Fix, FixAvailability, Violation}; use crate::{Edit, Fix, FixAvailability, Violation};
use ruff_macros::{ViolationMetadata, derive_message_formats}; use ruff_macros::{ViolationMetadata, derive_message_formats};
@ -211,7 +211,7 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
name: "AssetAny", name: "AssetAny",
}, },
"expand_alias_to_datasets" => Replacement::AutoImport { "expand_alias_to_datasets" => Replacement::AutoImport {
module: "airflow.sdk", module: "airflow.models.asset",
name: "expand_alias_to_assets", name: "expand_alias_to_assets",
}, },
_ => return, _ => return,
@ -256,7 +256,7 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
name: (*rest).to_string(), name: (*rest).to_string(),
}, },
["airflow", "models", "baseoperatorlink", "BaseOperatorLink"] => Replacement::AutoImport { ["airflow", "models", "baseoperatorlink", "BaseOperatorLink"] => Replacement::AutoImport {
module: "airflow.sdk.definitions.baseoperatorlink", module: "airflow.sdk",
name: "BaseOperatorLink", name: "BaseOperatorLink",
}, },
// airflow.model..DAG // airflow.model..DAG
@ -301,22 +301,16 @@ fn check_name(checker: &Checker, expr: &Expr, range: TextRange) {
if is_guarded_by_try_except(expr, module, name, checker.semantic()) { if is_guarded_by_try_except(expr, module, name, checker.semantic()) {
return; return;
} }
let mut diagnostic = checker.report_diagnostic(
checker Airflow3SuggestedUpdate {
.report_diagnostic( deprecated: qualified_name.to_string(),
Airflow3SuggestedUpdate { replacement: replacement.clone(),
deprecated: qualified_name.to_string(), },
replacement: replacement.clone(), range,
}, );
range, if let Some(fix) = generate_import_edit(expr, checker, module, name, range)
) .or_else(|| generate_remove_and_runtime_import_edit(expr, checker, module, name))
.try_set_fix(|| { {
let (import_edit, binding) = checker.importer().get_or_import_symbol( diagnostic.set_fix(fix);
&ImportRequest::import_from(module, name), }
expr.start(),
checker.semantic(),
)?;
let replacement_edit = Edit::range_replacement(binding, range);
Ok(Fix::safe_edits(import_edit, [replacement_edit]))
});
} }

View File

@ -1,404 +1,604 @@
--- ---
source: crates/ruff_linter/src/rules/airflow/mod.rs source: crates/ruff_linter/src/rules/airflow/mod.rs
--- ---
AIR311_names.py:27:1: AIR311 [*] `airflow.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:20:1: AIR311 [*] `airflow.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
26 | # airflow 19 | # airflow
27 | DatasetFromRoot() 20 | DatasetFromRoot()
| ^^^^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^^^^ AIR311
28 | 21 |
29 | # airflow.datasets 22 | # airflow.datasets
| |
= help: Use `Asset` from `airflow.sdk` instead. = help: Use `Asset` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 15 15 | task,
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 16 16 | task_group,
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 17 17 | )
25 |+from airflow.sdk import Asset 18 |+from airflow.sdk import Asset
25 26 | 18 19 |
26 27 | # airflow 19 20 | # airflow
27 |-DatasetFromRoot() 20 |-DatasetFromRoot()
28 |+Asset() 21 |+Asset()
28 29 | 21 22 |
29 30 | # airflow.datasets 22 23 | # airflow.datasets
30 31 | Dataset() 23 24 | Dataset()
AIR311_names.py:30:1: AIR311 [*] `airflow.datasets.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:23:1: AIR311 [*] `airflow.datasets.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
29 | # airflow.datasets 22 | # airflow.datasets
30 | Dataset() 23 | Dataset()
| ^^^^^^^ AIR311 | ^^^^^^^ AIR311
31 | DatasetAlias() 24 | DatasetAlias()
32 | DatasetAll() 25 | DatasetAll()
| |
= help: Use `Asset` from `airflow.sdk` instead. = help: Use `Asset` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 15 15 | task,
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 16 16 | task_group,
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 17 17 | )
25 |+from airflow.sdk import Asset 18 |+from airflow.sdk import Asset
25 26 | 18 19 |
26 27 | # airflow 19 20 | # airflow
27 28 | DatasetFromRoot() 20 21 | DatasetFromRoot()
28 29 | 21 22 |
29 30 | # airflow.datasets 22 23 | # airflow.datasets
30 |-Dataset() 23 |-Dataset()
31 |+Asset() 24 |+Asset()
31 32 | DatasetAlias() 24 25 | DatasetAlias()
32 33 | DatasetAll() 25 26 | DatasetAll()
33 34 | DatasetAny() 26 27 | DatasetAny()
AIR311_names.py:31:1: AIR311 [*] `airflow.datasets.DatasetAlias` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:24:1: AIR311 [*] `airflow.datasets.DatasetAlias` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
29 | # airflow.datasets 22 | # airflow.datasets
30 | Dataset() 23 | Dataset()
31 | DatasetAlias() 24 | DatasetAlias()
| ^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^ AIR311
32 | DatasetAll() 25 | DatasetAll()
33 | DatasetAny() 26 | DatasetAny()
| |
= help: Use `AssetAlias` from `airflow.sdk` instead. = help: Use `AssetAlias` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 15 15 | task,
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 16 16 | task_group,
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 17 17 | )
25 |+from airflow.sdk import AssetAlias 18 |+from airflow.sdk import AssetAlias
25 26 | 18 19 |
26 27 | # airflow 19 20 | # airflow
27 28 | DatasetFromRoot() 20 21 | DatasetFromRoot()
28 29 | 21 22 |
29 30 | # airflow.datasets 22 23 | # airflow.datasets
30 31 | Dataset() 23 24 | Dataset()
31 |-DatasetAlias() 24 |-DatasetAlias()
32 |+AssetAlias() 25 |+AssetAlias()
32 33 | DatasetAll() 25 26 | DatasetAll()
33 34 | DatasetAny() 26 27 | DatasetAny()
34 35 | Metadata() 27 28 | Metadata()
AIR311_names.py:32:1: AIR311 [*] `airflow.datasets.DatasetAll` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:25:1: AIR311 [*] `airflow.datasets.DatasetAll` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
30 | Dataset() 23 | Dataset()
31 | DatasetAlias() 24 | DatasetAlias()
32 | DatasetAll() 25 | DatasetAll()
| ^^^^^^^^^^ AIR311 | ^^^^^^^^^^ AIR311
33 | DatasetAny() 26 | DatasetAny()
34 | Metadata() 27 | Metadata()
| |
= help: Use `AssetAll` from `airflow.sdk` instead. = help: Use `AssetAll` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 15 15 | task,
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 16 16 | task_group,
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 17 17 | )
25 |+from airflow.sdk import AssetAll 18 |+from airflow.sdk import AssetAll
25 26 | 18 19 |
26 27 | # airflow 19 20 | # airflow
27 28 | DatasetFromRoot() 20 21 | DatasetFromRoot()
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
29 30 | # airflow.datasets 22 23 | # airflow.datasets
30 31 | Dataset() 23 24 | Dataset()
31 32 | DatasetAlias() 24 25 | DatasetAlias()
32 |-DatasetAll() 25 |-DatasetAll()
33 |+AssetAll() 26 |+AssetAll()
33 34 | DatasetAny() 26 27 | DatasetAny()
34 35 | Metadata() 27 28 | Metadata()
35 36 | expand_alias_to_datasets() 28 29 | expand_alias_to_datasets()
AIR311_names.py:33:1: AIR311 [*] `airflow.datasets.DatasetAny` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:26:1: AIR311 [*] `airflow.datasets.DatasetAny` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
31 | DatasetAlias() 24 | DatasetAlias()
32 | DatasetAll() 25 | DatasetAll()
33 | DatasetAny() 26 | DatasetAny()
| ^^^^^^^^^^ AIR311 | ^^^^^^^^^^ AIR311
34 | Metadata() 27 | Metadata()
35 | expand_alias_to_datasets() 28 | expand_alias_to_datasets()
| |
= help: Use `AssetAny` from `airflow.sdk` instead. = help: Use `AssetAny` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 15 15 | task,
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 16 16 | task_group,
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 17 17 | )
25 |+from airflow.sdk import AssetAny 18 |+from airflow.sdk import AssetAny
25 26 | 18 19 |
26 27 | # airflow 19 20 | # airflow
27 28 | DatasetFromRoot() 20 21 | DatasetFromRoot()
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
30 31 | Dataset() 23 24 | Dataset()
31 32 | DatasetAlias() 24 25 | DatasetAlias()
32 33 | DatasetAll() 25 26 | DatasetAll()
33 |-DatasetAny() 26 |-DatasetAny()
34 |+AssetAny() 27 |+AssetAny()
34 35 | Metadata() 27 28 | Metadata()
35 36 | expand_alias_to_datasets() 28 29 | expand_alias_to_datasets()
36 37 | 29 30 |
AIR311_names.py:34:1: AIR311 `airflow.datasets.metadata.Metadata` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:27:1: AIR311 [*] `airflow.datasets.metadata.Metadata` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
32 | DatasetAll() 25 | DatasetAll()
33 | DatasetAny() 26 | DatasetAny()
34 | Metadata() 27 | Metadata()
| ^^^^^^^^ AIR311 | ^^^^^^^^ AIR311
35 | expand_alias_to_datasets() 28 | expand_alias_to_datasets()
| |
= help: Use `Metadata` from `airflow.sdk` instead. = help: Use `Metadata` from `airflow.sdk` instead.
AIR311_names.py:35:1: AIR311 [*] `airflow.datasets.expand_alias_to_datasets` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
8 8 | DatasetAny,
9 9 | expand_alias_to_datasets,
10 10 | )
11 |-from airflow.datasets.metadata import Metadata
12 11 | from airflow.decorators import (
13 12 | dag,
14 13 | setup,
15 14 | task,
16 15 | task_group,
17 16 | )
17 |+from airflow.sdk import Metadata
18 18 |
19 19 | # airflow
20 20 | DatasetFromRoot()
AIR311_names.py:28:1: AIR311 [*] `airflow.datasets.expand_alias_to_datasets` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
33 | DatasetAny() 26 | DatasetAny()
34 | Metadata() 27 | Metadata()
35 | expand_alias_to_datasets() 28 | expand_alias_to_datasets()
| ^^^^^^^^^^^^^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR311
36 | 29 |
37 | # airflow.decorators 30 | # airflow.decorators
| |
= help: Use `expand_alias_to_assets` from `airflow.sdk` instead. = help: Use `expand_alias_to_assets` from `airflow.models.asset` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 15 15 | task,
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 16 16 | task_group,
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 17 17 | )
25 |+from airflow.sdk import expand_alias_to_assets 18 |+from airflow.models.asset import expand_alias_to_assets
25 26 | 18 19 |
26 27 | # airflow 19 20 | # airflow
27 28 | DatasetFromRoot() 20 21 | DatasetFromRoot()
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
32 33 | DatasetAll() 25 26 | DatasetAll()
33 34 | DatasetAny() 26 27 | DatasetAny()
34 35 | Metadata() 27 28 | Metadata()
35 |-expand_alias_to_datasets() 28 |-expand_alias_to_datasets()
36 |+expand_alias_to_assets() 29 |+expand_alias_to_assets()
36 37 | 29 30 |
37 38 | # airflow.decorators 30 31 | # airflow.decorators
38 39 | dag() 31 32 | dag()
AIR311_names.py:38:1: AIR311 `airflow.decorators.dag` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:31:1: AIR311 [*] `airflow.decorators.dag` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
37 | # airflow.decorators 30 | # airflow.decorators
38 | dag() 31 | dag()
| ^^^ AIR311 | ^^^ AIR311
39 | task() 32 | task()
40 | task_group() 33 | task_group()
| |
= help: Use `dag` from `airflow.sdk` instead. = help: Use `dag` from `airflow.sdk` instead.
AIR311_names.py:39:1: AIR311 `airflow.decorators.task` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
10 10 | )
11 11 | from airflow.datasets.metadata import Metadata
12 12 | from airflow.decorators import (
13 |- dag,
14 13 | setup,
15 14 | task,
16 15 | task_group,
17 16 | )
17 |+from airflow.sdk import dag
18 18 |
19 19 | # airflow
20 20 | DatasetFromRoot()
AIR311_names.py:32:1: AIR311 [*] `airflow.decorators.task` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
37 | # airflow.decorators 30 | # airflow.decorators
38 | dag() 31 | dag()
39 | task() 32 | task()
| ^^^^ AIR311 | ^^^^ AIR311
40 | task_group() 33 | task_group()
41 | setup() 34 | setup()
| |
= help: Use `task` from `airflow.sdk` instead. = help: Use `task` from `airflow.sdk` instead.
AIR311_names.py:40:1: AIR311 `airflow.decorators.task_group` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
12 12 | from airflow.decorators import (
13 13 | dag,
14 14 | setup,
15 |- task,
16 15 | task_group,
17 16 | )
17 |+from airflow.sdk import task
18 18 |
19 19 | # airflow
20 20 | DatasetFromRoot()
AIR311_names.py:33:1: AIR311 [*] `airflow.decorators.task_group` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
38 | dag() 31 | dag()
39 | task() 32 | task()
40 | task_group() 33 | task_group()
| ^^^^^^^^^^ AIR311 | ^^^^^^^^^^ AIR311
41 | setup() 34 | setup()
42 | teardown() 35 | from airflow.decorators import teardown
| |
= help: Use `task_group` from `airflow.sdk` instead. = help: Use `task_group` from `airflow.sdk` instead.
AIR311_names.py:41:1: AIR311 `airflow.decorators.setup` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
13 13 | dag,
14 14 | setup,
15 15 | task,
16 |- task_group,
17 16 | )
17 |+from airflow.sdk import task_group
18 18 |
19 19 | # airflow
20 20 | DatasetFromRoot()
AIR311_names.py:34:1: AIR311 [*] `airflow.decorators.setup` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
39 | task() 32 | task()
40 | task_group() 33 | task_group()
41 | setup() 34 | setup()
| ^^^^^ AIR311 | ^^^^^ AIR311
42 | teardown() 35 | from airflow.decorators import teardown
36 | from airflow.io.path import ObjectStoragePath
| |
= help: Use `setup` from `airflow.sdk` instead. = help: Use `setup` from `airflow.sdk` instead.
AIR311_names.py:42:1: AIR311 `airflow.decorators.teardown` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
11 11 | from airflow.datasets.metadata import Metadata
12 12 | from airflow.decorators import (
13 13 | dag,
14 |- setup,
15 14 | task,
16 15 | task_group,
17 16 | )
17 |+from airflow.sdk import setup
18 18 |
19 19 | # airflow
20 20 | DatasetFromRoot()
AIR311_names.py:48:1: AIR311 [*] `airflow.decorators.teardown` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
40 | task_group() 47 | # airflow.decorators
41 | setup() 48 | teardown()
42 | teardown()
| ^^^^^^^^ AIR311 | ^^^^^^^^ AIR311
43 | 49 |
44 | # airflow.io 50 | # # airflow.io
| |
= help: Use `teardown` from `airflow.sdk` instead. = help: Use `teardown` from `airflow.sdk` instead.
AIR311_names.py:45:1: AIR311 `airflow.io.path.ObjectStoragePath` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
32 32 | task()
33 33 | task_group()
34 34 | setup()
35 |-from airflow.decorators import teardown
36 35 | from airflow.io.path import ObjectStoragePath
37 36 | from airflow.io.storage import attach
38 37 | from airflow.models import DAG as DAGFromModel
--------------------------------------------------------------------------------
43 42 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
44 43 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 44 | from airflow.models.dag import DAG as DAGFromDag
45 |+from airflow.sdk import teardown
46 46 |
47 47 | # airflow.decorators
48 48 | teardown()
AIR311_names.py:51:1: AIR311 [*] `airflow.io.path.ObjectStoragePath` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
44 | # airflow.io 50 | # # airflow.io
45 | ObjectStoragePath() 51 | ObjectStoragePath()
| ^^^^^^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^^^^^^ AIR311
46 | attach() 52 | attach()
| |
= help: Use `ObjectStoragePath` from `airflow.sdk` instead. = help: Use `ObjectStoragePath` from `airflow.sdk` instead.
AIR311_names.py:46:1: AIR311 `airflow.io.storage.attach` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
33 33 | task_group()
34 34 | setup()
35 35 | from airflow.decorators import teardown
36 |-from airflow.io.path import ObjectStoragePath
37 36 | from airflow.io.storage import attach
38 37 | from airflow.models import DAG as DAGFromModel
39 38 | from airflow.models import (
--------------------------------------------------------------------------------
43 42 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
44 43 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 44 | from airflow.models.dag import DAG as DAGFromDag
45 |+from airflow.sdk import ObjectStoragePath
46 46 |
47 47 | # airflow.decorators
48 48 | teardown()
AIR311_names.py:52:1: AIR311 [*] `airflow.io.storage.attach` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
44 | # airflow.io 50 | # # airflow.io
45 | ObjectStoragePath() 51 | ObjectStoragePath()
46 | attach() 52 | attach()
| ^^^^^^ AIR311 | ^^^^^^ AIR311
47 | 53 |
48 | # airflow.models 54 | # airflow.models
| |
= help: Use `attach` from `airflow.sdk.io` instead. = help: Use `attach` from `airflow.sdk.io` instead.
AIR311_names.py:49:1: AIR311 `airflow.models.Connection` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
34 34 | setup()
35 35 | from airflow.decorators import teardown
36 36 | from airflow.io.path import ObjectStoragePath
37 |-from airflow.io.storage import attach
38 37 | from airflow.models import DAG as DAGFromModel
39 38 | from airflow.models import (
40 39 | Connection,
--------------------------------------------------------------------------------
43 42 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
44 43 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 44 | from airflow.models.dag import DAG as DAGFromDag
45 |+from airflow.sdk.io import attach
46 46 |
47 47 | # airflow.decorators
48 48 | teardown()
AIR311_names.py:55:1: AIR311 [*] `airflow.models.Connection` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
48 | # airflow.models 54 | # airflow.models
49 | Connection() 55 | Connection()
| ^^^^^^^^^^ AIR311 | ^^^^^^^^^^ AIR311
50 | DAGFromModel() 56 | DAGFromModel()
51 | Variable() 57 | Variable()
| |
= help: Use `Connection` from `airflow.sdk` instead. = help: Use `Connection` from `airflow.sdk` instead.
AIR311_names.py:50:1: AIR311 [*] `airflow.models.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
37 37 | from airflow.io.storage import attach
38 38 | from airflow.models import DAG as DAGFromModel
39 39 | from airflow.models import (
40 |- Connection,
41 40 | Variable,
42 41 | )
43 42 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
44 43 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 44 | from airflow.models.dag import DAG as DAGFromDag
45 |+from airflow.sdk import Connection
46 46 |
47 47 | # airflow.decorators
48 48 | teardown()
AIR311_names.py:56:1: AIR311 [*] `airflow.models.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
48 | # airflow.models 54 | # airflow.models
49 | Connection() 55 | Connection()
50 | DAGFromModel() 56 | DAGFromModel()
| ^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^ AIR311
51 | Variable() 57 | Variable()
| |
= help: Use `DAG` from `airflow.sdk` instead. = help: Use `DAG` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 43 43 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 44 44 | from airflow.models.baseoperatorlink import BaseOperatorLink
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 45 45 | from airflow.models.dag import DAG as DAGFromDag
25 |+from airflow.sdk import DAG 46 |+from airflow.sdk import DAG
25 26 | 46 47 |
26 27 | # airflow 47 48 | # airflow.decorators
27 28 | DatasetFromRoot() 48 49 | teardown()
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
47 48 | 53 54 |
48 49 | # airflow.models 54 55 | # airflow.models
49 50 | Connection() 55 56 | Connection()
50 |-DAGFromModel() 56 |-DAGFromModel()
51 |+DAG() 57 |+DAG()
51 52 | Variable() 57 58 | Variable()
52 53 | 58 59 |
53 54 | # airflow.models.baseoperator 59 60 | # airflow.models.baseoperator
AIR311_names.py:51:1: AIR311 `airflow.models.Variable` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:57:1: AIR311 [*] `airflow.models.Variable` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
49 | Connection() 55 | Connection()
50 | DAGFromModel() 56 | DAGFromModel()
51 | Variable() 57 | Variable()
| ^^^^^^^^ AIR311 | ^^^^^^^^ AIR311
52 | 58 |
53 | # airflow.models.baseoperator 59 | # airflow.models.baseoperator
| |
= help: Use `Variable` from `airflow.sdk` instead. = help: Use `Variable` from `airflow.sdk` instead.
AIR311_names.py:54:1: AIR311 `airflow.models.baseoperator.chain` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
38 38 | from airflow.models import DAG as DAGFromModel
39 39 | from airflow.models import (
40 40 | Connection,
41 |- Variable,
42 41 | )
43 42 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
44 43 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 44 | from airflow.models.dag import DAG as DAGFromDag
45 |+from airflow.sdk import Variable
46 46 |
47 47 | # airflow.decorators
48 48 | teardown()
AIR311_names.py:60:1: AIR311 [*] `airflow.models.baseoperator.chain` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
53 | # airflow.models.baseoperator 59 | # airflow.models.baseoperator
54 | chain() 60 | chain()
| ^^^^^ AIR311 | ^^^^^ AIR311
55 | chain_linear() 61 | chain_linear()
56 | cross_downstream() 62 | cross_downstream()
| |
= help: Use `chain` from `airflow.sdk` instead. = help: Use `chain` from `airflow.sdk` instead.
AIR311_names.py:55:1: AIR311 `airflow.models.baseoperator.chain_linear` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
40 40 | Connection,
41 41 | Variable,
42 42 | )
43 |-from airflow.models.baseoperator import chain, chain_linear, cross_downstream
43 |+from airflow.models.baseoperator import chain_linear, cross_downstream
44 44 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 45 | from airflow.models.dag import DAG as DAGFromDag
46 |+from airflow.sdk import chain
46 47 |
47 48 | # airflow.decorators
48 49 | teardown()
AIR311_names.py:61:1: AIR311 [*] `airflow.models.baseoperator.chain_linear` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
53 | # airflow.models.baseoperator 59 | # airflow.models.baseoperator
54 | chain() 60 | chain()
55 | chain_linear() 61 | chain_linear()
| ^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^ AIR311
56 | cross_downstream() 62 | cross_downstream()
| |
= help: Use `chain_linear` from `airflow.sdk` instead. = help: Use `chain_linear` from `airflow.sdk` instead.
AIR311_names.py:56:1: AIR311 `airflow.models.baseoperator.cross_downstream` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
40 40 | Connection,
41 41 | Variable,
42 42 | )
43 |-from airflow.models.baseoperator import chain, chain_linear, cross_downstream
43 |+from airflow.models.baseoperator import chain, cross_downstream
44 44 | from airflow.models.baseoperatorlink import BaseOperatorLink
45 45 | from airflow.models.dag import DAG as DAGFromDag
46 |+from airflow.sdk import chain_linear
46 47 |
47 48 | # airflow.decorators
48 49 | teardown()
AIR311_names.py:62:1: AIR311 [*] `airflow.models.baseoperator.cross_downstream` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
54 | chain() 60 | chain()
55 | chain_linear() 61 | chain_linear()
56 | cross_downstream() 62 | cross_downstream()
| ^^^^^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^^^^^ AIR311
57 | 63 |
58 | # airflow.models.baseoperatolinker 64 | # airflow.models.baseoperatolinker
| |
= help: Use `cross_downstream` from `airflow.sdk` instead. = help: Use `cross_downstream` from `airflow.sdk` instead.
AIR311_names.py:59:1: AIR311 `airflow.models.baseoperatorlink.BaseOperatorLink` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. Unsafe fix
| 40 40 | Connection,
58 | # airflow.models.baseoperatolinker 41 41 | Variable,
59 | BaseOperatorLink() 42 42 | )
| ^^^^^^^^^^^^^^^^ AIR311 43 |-from airflow.models.baseoperator import chain, chain_linear, cross_downstream
60 | 43 |+from airflow.models.baseoperator import chain, chain_linear
61 | # airflow.models.dag 44 44 | from airflow.models.baseoperatorlink import BaseOperatorLink
| 45 45 | from airflow.models.dag import DAG as DAGFromDag
= help: Use `BaseOperatorLink` from `airflow.sdk.definitions.baseoperatorlink` instead. 46 |+from airflow.sdk import cross_downstream
46 47 |
47 48 | # airflow.decorators
48 49 | teardown()
AIR311_names.py:62:1: AIR311 [*] `airflow.models.dag.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:65:1: AIR311 [*] `airflow.models.baseoperatorlink.BaseOperatorLink` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
61 | # airflow.models.dag 64 | # airflow.models.baseoperatolinker
62 | DAGFromDag() 65 | BaseOperatorLink()
| ^^^^^^^^^^^^^^^^ AIR311
66 |
67 | # airflow.models.dag
|
= help: Use `BaseOperatorLink` from `airflow.sdk` instead.
Unsafe fix
41 41 | Variable,
42 42 | )
43 43 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
44 |-from airflow.models.baseoperatorlink import BaseOperatorLink
45 44 | from airflow.models.dag import DAG as DAGFromDag
45 |+from airflow.sdk import BaseOperatorLink
46 46 |
47 47 | # airflow.decorators
48 48 | teardown()
AIR311_names.py:68:1: AIR311 [*] `airflow.models.dag.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
|
67 | # airflow.models.dag
68 | DAGFromDag()
| ^^^^^^^^^^ AIR311 | ^^^^^^^^^^ AIR311
63 | # airflow.timetables.datasets 69 | from airflow.timetables.datasets import DatasetOrTimeSchedule
64 | DatasetOrTimeSchedule() 70 | from airflow.utils.dag_parsing_context import get_parsing_context
| |
= help: Use `DAG` from `airflow.sdk` instead. = help: Use `DAG` from `airflow.sdk` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 43 43 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 44 44 | from airflow.models.baseoperatorlink import BaseOperatorLink
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 45 45 | from airflow.models.dag import DAG as DAGFromDag
25 |+from airflow.sdk import DAG 46 |+from airflow.sdk import DAG
25 26 | 46 47 |
26 27 | # airflow 47 48 | # airflow.decorators
27 28 | DatasetFromRoot() 48 49 | teardown()
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
59 60 | BaseOperatorLink() 65 66 | BaseOperatorLink()
60 61 | 66 67 |
61 62 | # airflow.models.dag 67 68 | # airflow.models.dag
62 |-DAGFromDag() 68 |-DAGFromDag()
63 |+DAG() 69 |+DAG()
63 64 | # airflow.timetables.datasets 69 70 | from airflow.timetables.datasets import DatasetOrTimeSchedule
64 65 | DatasetOrTimeSchedule() 70 71 | from airflow.utils.dag_parsing_context import get_parsing_context
65 66 | 71 72 |
AIR311_names.py:64:1: AIR311 [*] `airflow.timetables.datasets.DatasetOrTimeSchedule` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:73:1: AIR311 [*] `airflow.timetables.datasets.DatasetOrTimeSchedule` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
62 | DAGFromDag() 72 | # airflow.timetables.datasets
63 | # airflow.timetables.datasets 73 | DatasetOrTimeSchedule()
64 | DatasetOrTimeSchedule()
| ^^^^^^^^^^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^^^^^^^^^^ AIR311
65 | 74 |
66 | # airflow.utils.dag_parsing_context 75 | # airflow.utils.dag_parsing_context
| |
= help: Use `AssetOrTimeSchedule` from `airflow.timetables.assets` instead. = help: Use `AssetOrTimeSchedule` from `airflow.timetables.assets` instead.
Safe fix Safe fix
22 22 | from airflow.models.dag import DAG as DAGFromDag 68 68 | DAGFromDag()
23 23 | from airflow.timetables.datasets import DatasetOrTimeSchedule 69 69 | from airflow.timetables.datasets import DatasetOrTimeSchedule
24 24 | from airflow.utils.dag_parsing_context import get_parsing_context 70 70 | from airflow.utils.dag_parsing_context import get_parsing_context
25 |+from airflow.timetables.assets import AssetOrTimeSchedule 71 |+from airflow.timetables.assets import AssetOrTimeSchedule
25 26 | 71 72 |
26 27 | # airflow 72 73 | # airflow.timetables.datasets
27 28 | DatasetFromRoot() 73 |-DatasetOrTimeSchedule()
-------------------------------------------------------------------------------- 74 |+AssetOrTimeSchedule()
61 62 | # airflow.models.dag 74 75 |
62 63 | DAGFromDag() 75 76 | # airflow.utils.dag_parsing_context
63 64 | # airflow.timetables.datasets 76 77 | get_parsing_context()
64 |-DatasetOrTimeSchedule()
65 |+AssetOrTimeSchedule()
65 66 |
66 67 | # airflow.utils.dag_parsing_context
67 68 | get_parsing_context()
AIR311_names.py:67:1: AIR311 `airflow.utils.dag_parsing_context.get_parsing_context` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. AIR311_names.py:76:1: AIR311 [*] `airflow.utils.dag_parsing_context.get_parsing_context` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
| |
66 | # airflow.utils.dag_parsing_context 75 | # airflow.utils.dag_parsing_context
67 | get_parsing_context() 76 | get_parsing_context()
| ^^^^^^^^^^^^^^^^^^^ AIR311 | ^^^^^^^^^^^^^^^^^^^ AIR311
| |
= help: Use `get_parsing_context` from `airflow.sdk` instead. = help: Use `get_parsing_context` from `airflow.sdk` instead.
Unsafe fix
67 67 | # airflow.models.dag
68 68 | DAGFromDag()
69 69 | from airflow.timetables.datasets import DatasetOrTimeSchedule
70 |-from airflow.utils.dag_parsing_context import get_parsing_context
70 |+from airflow.sdk import get_parsing_context
71 71 |
72 72 | # airflow.timetables.datasets
73 73 | DatasetOrTimeSchedule()