ashb commented on a change in pull request #19914:
URL: https://github.com/apache/airflow/pull/19914#discussion_r763880444
##########
File path: airflow/utils/db.py
##########
@@ -58,22 +59,28 @@
log = logging.getLogger(__name__)
+SESSION_MUST_BE_ASSIGNED = "The session should be assigned here. This is a
critical assertion."
+
def _format_airflow_moved_table_name(source_table, version):
return "__".join([settings.AIRFLOW_MOVED_TABLE_PREFIX,
version.replace(".", "_"), source_table])
@provide_session
-def merge_conn(conn, session=None):
+def merge_conn(conn, session: Optional[SASession] = None):
"""Add new Connection."""
+ if not session:
+ raise RuntimeError(SESSION_MUST_BE_ASSIGNED)
if not session.query(Connection).filter(Connection.conn_id ==
conn.conn_id).first():
session.add(conn)
session.commit()
@provide_session
-def add_default_pool_if_not_exists(session=None):
+def add_default_pool_if_not_exists(session: Optional[SASession] = None):
"""Add default pool if it does not exist."""
+ if not session:
+ raise RuntimeError(SESSION_MUST_BE_ASSIGNED)
Review comment:
@uranusjr has a better plan for this that doesn't have a runtime impact.
--
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]