From 031028dbac86bc93875329b30f20cdf10fda35c7 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Tue, 28 Jan 2025 02:22:55 +0100 Subject: [PATCH] Satisfy Mypy for Livy Hook (#46157) The Livy Hook shows ... strange MyPy errors and hard to say why. First of all it incorrectly used multiple inheritance (BaseHook already inherist from LoggingMixin) but then it seems that mypy has been lost when it comes to fields available in the hook. Setting them directly (like it happens in other hooks deriving from HttpHook solves the MyPy issues. --- .../src/airflow/providers/apache/livy/hooks/livy.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/providers/src/airflow/providers/apache/livy/hooks/livy.py b/providers/src/airflow/providers/apache/livy/hooks/livy.py index 3eec9599457fe..934985befbc91 100644 --- a/providers/src/airflow/providers/apache/livy/hooks/livy.py +++ b/providers/src/airflow/providers/apache/livy/hooks/livy.py @@ -32,7 +32,6 @@ from airflow.exceptions import AirflowException from airflow.providers.http.hooks.http import HttpAsyncHook, HttpHook -from airflow.utils.log.logging_mixin import LoggingMixin if TYPE_CHECKING: from airflow.models import Connection @@ -53,7 +52,7 @@ class BatchState(Enum): SUCCESS = "success" -class LivyHook(HttpHook, LoggingMixin): +class LivyHook(HttpHook): """ Hook for Apache Livy through the REST API. @@ -88,7 +87,9 @@ def __init__( extra_headers: dict[str, Any] | None = None, auth_type: Any | None = None, ) -> None: - super().__init__(http_conn_id=livy_conn_id) + super().__init__() + self.method = "POST" + self.http_conn_id = livy_conn_id self.extra_headers = extra_headers or {} self.extra_options = extra_options or {} if auth_type: @@ -457,7 +458,7 @@ def _validate_extra_conf(conf: dict[Any, Any]) -> bool: return True -class LivyAsyncHook(HttpAsyncHook, LoggingMixin): +class LivyAsyncHook(HttpAsyncHook): """ Hook for Apache Livy through the REST API asynchronously. @@ -490,7 +491,9 @@ def __init__( extra_options: dict[str, Any] | None = None, extra_headers: dict[str, Any] | None = None, ) -> None: - super().__init__(http_conn_id=livy_conn_id) + super().__init__() + self.method = "POST" + self.http_conn_id = livy_conn_id self.extra_headers = extra_headers or {} self.extra_options = extra_options or {}