uranusjr commented on code in PR #40069:
URL: https://github.com/apache/airflow/pull/40069#discussion_r1630851968


##########
airflow/settings.py:
##########
@@ -278,17 +278,24 @@ def remove(*args, **kwargs):
         pass
 
 
+def _is_sqlite_db_path_relative(sqla_conn_str: str) -> bool:
+    """Determine whether the database connection URI specifies a relative 
path."""
+    import re2
+
+    return (
+        bool(sqla_conn_str)
+        and sqla_conn_str.startswith("sqlite")
+        # In memory is not useful for production, but useful for writing tests 
against Airflow for extensions
+        and sqla_conn_str != "sqlite://"
+        and not os.path.isabs(re2.sub(r"^sqlite:///", "", sqla_conn_str))
+    )

Review Comment:
   If this is to be split into a separate function, I would use early returns 
to make this giant `and` chain more readable. Also I would not use regex here; 
it is enough to simply check there are exactly three slashes, and feed 
`sqla_conn_str[10:]` to `isabs`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to