From 85f8df7b8a18e1147c7e014a7af7fc4e66aaa8be Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Wed, 18 Jan 2023 18:11:59 +0800 Subject: [PATCH] Remove conn.close() ignores (#29005) --- .../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 4a478ef996299b..ab0b1c9a32dd5f 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() # type: ignore[misc] + conn.close() 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 ea2d912a62c616..83a25f1aeda6ab 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) # type: ignore[operator] + conn.autocommit(autocommit) 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() # type: ignore[union-attr] + return conn.get_autocommit() 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() # type: ignore[misc] + conn.close() 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() # type: ignore[misc] + conn.close() @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() # type: ignore[misc] + conn.close()