From a2a055a08ab8b41eaa94f810c6f5ee8a0e330e8b Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Wed, 18 Jan 2023 11:38:54 +0100 Subject: [PATCH] Revert "Remove conn.close() ignores (#29005)" This reverts commit 85f8df7b8a18e1147c7e014a7af7fc4e66aaa8be. --- .../providers/apache/hive/transfers/mysql_to_hive.py | 2 +- airflow/providers/mysql/hooks/mysql.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/airflow/providers/apache/hive/transfers/mysql_to_hive.py b/airflow/providers/apache/hive/transfers/mysql_to_hive.py index ab0b1c9a32dd5..4a478ef996299 100644 --- a/airflow/providers/apache/hive/transfers/mysql_to_hive.py +++ b/airflow/providers/apache/hive/transfers/mysql_to_hive.py @@ -149,7 +149,7 @@ def execute(self, context: Context): csv_writer.writerows(cursor) f.flush() cursor.close() - conn.close() + conn.close() # type: ignore[misc] self.log.info("Loading file into Hive") hive.load_file( f.name, diff --git a/airflow/providers/mysql/hooks/mysql.py b/airflow/providers/mysql/hooks/mysql.py index 83a25f1aeda6a..ea2d912a62c61 100644 --- a/airflow/providers/mysql/hooks/mysql.py +++ b/airflow/providers/mysql/hooks/mysql.py @@ -78,7 +78,7 @@ def set_autocommit(self, conn: MySQLConnectionTypes, autocommit: bool) -> None: if hasattr(conn.__class__, "autocommit") and isinstance(conn.__class__.autocommit, property): conn.autocommit = autocommit else: - conn.autocommit(autocommit) + conn.autocommit(autocommit) # type: ignore[operator] def get_autocommit(self, conn: MySQLConnectionTypes) -> bool: """ @@ -93,7 +93,7 @@ def get_autocommit(self, conn: MySQLConnectionTypes) -> bool: if hasattr(conn.__class__, "autocommit") and isinstance(conn.__class__.autocommit, property): return conn.autocommit else: - return conn.get_autocommit() + return conn.get_autocommit() # type: ignore[union-attr] def _get_conn_config_mysql_client(self, conn: Connection) -> dict: conn_config = { @@ -199,7 +199,7 @@ def bulk_load(self, table: str, tmp_file: str) -> None: """ ) conn.commit() - conn.close() + conn.close() # type: ignore[misc] def bulk_dump(self, table: str, tmp_file: str) -> None: """Dump a database table into a tab-delimited file.""" @@ -212,7 +212,7 @@ def bulk_dump(self, table: str, tmp_file: str) -> None: """ ) conn.commit() - conn.close() + conn.close() # type: ignore[misc] @staticmethod def _serialize_cell(cell: object, conn: Connection | None = None) -> Any: @@ -283,4 +283,4 @@ def bulk_load_custom( cursor.close() conn.commit() - conn.close() + conn.close() # type: ignore[misc]