You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/01/04 12:40:08 UTC

[airflow] branch main updated: Limit SQLAlchemy to below 2.0 (#28725)

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

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 93fed0cf5e Limit SQLAlchemy to below 2.0 (#28725)
93fed0cf5e is described below

commit 93fed0cf5eeed5dbea9f261370149206232fca98
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Wed Jan 4 13:39:50 2023 +0100

    Limit SQLAlchemy to below 2.0 (#28725)
    
    SQLAlchemy is about to release 2.0 version and in 1.46 version it
    started to warn about deprecated features that are used. This
    (nicely) started to fail our builds - so our canary tests caught
    it early and gave us a chance to prepare for the 2.0 release and
    limit Airflow's dependencies beforehand.
    
    This PR adds the deprecation as "known" and limits SQLAlchemy to
    be <2.0 (and links to appropriate issues and documentation)
---
 scripts/in_container/verify_providers.py | 7 ++++---
 setup.cfg                                | 6 +++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/scripts/in_container/verify_providers.py b/scripts/in_container/verify_providers.py
index 87d79ee6ca..d46e32caa3 100755
--- a/scripts/in_container/verify_providers.py
+++ b/scripts/in_container/verify_providers.py
@@ -231,6 +231,7 @@ KNOWN_COMMON_DEPRECATED_MESSAGES: set[str] = {
     "Please use `schedule` instead. ",
     "'urllib3.contrib.pyopenssl' module is deprecated and will be removed in a future "
     "release of urllib3 2.x. Read more in this issue: https://github.com/urllib3/urllib3/issues/2680",
+    "Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0",
 }
 
 # The set of warning messages generated by direct importing of some deprecated modules. We should only
@@ -260,7 +261,7 @@ KNOWN_DEPRECATED_DIRECT_IMPORTS: set[str] = {
 def filter_known_warnings(warn: warnings.WarningMessage) -> bool:
     msg_string = str(warn.message).replace("\n", " ")
     for message, origin in KNOWN_DEPRECATED_MESSAGES:
-        if msg_string == message and warn.filename.find(f"/{origin}/") != -1:
+        if message in msg_string and warn.filename.find(f"/{origin}/") != -1:
             return False
     return True
 
@@ -268,7 +269,7 @@ def filter_known_warnings(warn: warnings.WarningMessage) -> bool:
 def filter_direct_importlib_warning(warn: warnings.WarningMessage) -> bool:
     msg_string = str(warn.message).replace("\n", " ")
     for m in KNOWN_DEPRECATED_DIRECT_IMPORTS:
-        if msg_string == m and warn.filename.find("/importlib/") != -1:
+        if m in msg_string and warn.filename.find("/importlib/") != -1:
             return False
     return True
 
@@ -276,7 +277,7 @@ def filter_direct_importlib_warning(warn: warnings.WarningMessage) -> bool:
 def filter_known_common_deprecated_messages(warn: warnings.WarningMessage) -> bool:
     msg_string = str(warn.message).replace("\n", " ")
     for m in KNOWN_COMMON_DEPRECATED_MESSAGES:
-        if msg_string == m:
+        if m in msg_string:
             return False
     return True
 
diff --git a/setup.cfg b/setup.cfg
index 5cc2a1342b..868065c398 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -125,7 +125,11 @@ install_requires =
     python-slugify>=5.0
     rich>=12.4.4
     setproctitle>=1.1.8
-    sqlalchemy>=1.4
+    # We use some deprecated features of sqlalchemy 2.0 and we should replace them before we can upgrade
+    # See https://sqlalche.me/e/b8d9 for details of deprecated features
+    # you can set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.
+    # The issue tracking it is https://github.com/apache/airflow/issues/28723
+    sqlalchemy>=1.4,<2.0
     sqlalchemy_jsonfield>=1.0
     tabulate>=0.7.5
     tenacity>=6.2.0