You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/03/10 19:51:16 UTC
[airflow] branch v1-10-stable updated: Fix wrong warning about
class that was not used in a dag file (#14700)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch v1-10-stable
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v1-10-stable by this push:
new 6edf6aa Fix wrong warning about class that was not used in a dag file (#14700)
6edf6aa is described below
commit 6edf6aa19a64a20832904336ddf7728c7b77a098
Author: Ephraim Anierobi <sp...@gmail.com>
AuthorDate: Wed Mar 10 20:51:00 2021 +0100
Fix wrong warning about class that was not used in a dag file (#14700)
Running upgrade_check with this import in a dag:
from airflow.operators.slack_operator import SlackAPIPostOperator
Causes these warnings:
[1] Using `airflow.operators.slack_operator.SlackAPIPostOperator` should be replaced by `airflow.providers.slack.operators.slack.SlackAPIPostOperator`.
[2] Using `airflow.operators.slack_operator.SlackAPIOperator` should be replaced by `airflow.providers.slack.operators.slack.SlackAPIOperator`
Only 1 above is correct.
This PR fixes it by checking that both the old import part and class name exists in the dag before issuing warning
---
airflow/upgrade/rules/import_changes.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/airflow/upgrade/rules/import_changes.py b/airflow/upgrade/rules/import_changes.py
index 5ee4047..e9d0166 100644
--- a/airflow/upgrade/rules/import_changes.py
+++ b/airflow/upgrade/rules/import_changes.py
@@ -53,6 +53,10 @@ class ImportChange(
return ".".join(part)
@cached_property
+ def old_class(self):
+ return self.old_path.split(".")[-1]
+
+ @cached_property
def new_class(self):
return self.new_path.split(".")[-1]
@@ -116,7 +120,7 @@ class ImportChangesRule(BaseRule):
try:
content = file.read()
for change in ImportChangesRule.ALL_CHANGES:
- if change.old_path_without_classname in content:
+ if change.old_path_without_classname in content and change.old_class in content:
problems.append(change.info(file_path))
if change.providers_package:
providers.add(change.providers_package)