You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2020/12/11 13:26:18 UTC

[airflow] branch v1-10-stable updated: Don't suggest change to users that will break dags on 1.1o.x (#13012)

This is an automated email from the ASF dual-hosted git repository.

ash 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 dd58fe6  Don't suggest change to users that will break dags on 1.1o.x (#13012)
dd58fe6 is described below

commit dd58fe6b4e673f79c4a61d93d497e771d7d31435
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Fri Dec 11 13:25:23 2020 +0000

    Don't suggest change to users that will break dags on 1.1o.x (#13012)
    
    We don't have airflow.operators.python etc in 1.10.x, so suggesting
    users change this would break their dags currently.
    
    Closes #12895
---
 airflow/upgrade/rules/import_changes.py | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/airflow/upgrade/rules/import_changes.py b/airflow/upgrade/rules/import_changes.py
index 7f5bc80..317549d 100644
--- a/airflow/upgrade/rules/import_changes.py
+++ b/airflow/upgrade/rules/import_changes.py
@@ -39,7 +39,9 @@ class ImportChange(
     )
 ):
     def info(self, file_path=None):
-        msg = "Using `{}` should be replaced by `{}`".format(self.old_path, self.new_path)
+        msg = "Using `{}` should be replaced by `{}`".format(
+            self.old_path, self.new_path
+        )
         if file_path:
             msg += ". Affected file: {}".format(file_path)
         return msg
@@ -80,10 +82,30 @@ class ImportChangesRule(BaseRule):
         "https://github.com/apache/airflow#backport-packages"
     )
 
+    current_airflow_version = Version(__import__("airflow").__version__)
+
+    if current_airflow_version < Version("2.0.0"):
+
+        def _filter_incompatible_renames(arg):
+            new_path = arg[1]
+            return (
+                not new_path.startswith("airflow.operators")
+                and not new_path.startswith("airflow.sensors")
+                and not new_path.startswith("airflow.hooks")
+            )
+
+    else:
+        # Everything allowed on 2.0.0+
+        def _filter_incompatible_renames(arg):
+            return True
+
     ALL_CHANGES = [
-        ImportChange.from_new_old_paths(*args) for args in ALL
+        ImportChange.from_new_old_paths(*args)
+        for args in filter(_filter_incompatible_renames, ALL)
     ]  # type: List[ImportChange]
 
+    del _filter_incompatible_renames
+
     @staticmethod
     def _check_file(file_path):
         problems = []