Skip to content

Commit

Permalink
fix: fixes static checks and moves Row import
Browse files Browse the repository at this point in the history
  • Loading branch information
dcmshi committed Oct 30, 2024
1 parent 9a3ba55 commit 90ede99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion providers/src/airflow/providers/common/sql/sensors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(
self.parameters = parameters
self.success = success
self.failure = failure
self.selector = selector or itemgetter(0)
self.selector = selector
self.fail_on_empty = fail_on_empty
self.hook_params = hook_params
super().__init__(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@
Any,
Callable,
Iterable,
List,
Optional,
Mapping,
Sequence,
TypeVar,
Union,
cast,
overload,
)

from databricks import sql # type: ignore[attr-defined]
from databricks.sql.types import Row

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.models.connection import Connection as AirflowConnection
Expand All @@ -44,15 +42,14 @@

if TYPE_CHECKING:
from databricks.sql.client import Connection
from databricks.sql.types import Row


LIST_SQL_ENDPOINTS_ENDPOINT = ("GET", "api/2.0/sql/endpoints")


T = TypeVar("T")



class DatabricksSqlHook(BaseDatabricksHook, DbApiHook):
"""
Hook to interact with Databricks SQL.
Expand Down Expand Up @@ -94,7 +91,7 @@ def __init__(
**kwargs,
) -> None:
super().__init__(databricks_conn_id, caller=caller)
self._sql_conn: Optional[Connection] = None
self._sql_conn: Connection | None = None
self._token: str | None = None
self._http_path = http_path
self._sql_endpoint_name = sql_endpoint_name
Expand Down Expand Up @@ -275,7 +272,7 @@ def run(
else:
return results

def _make_common_data_structure(self, result: Union[T, Sequence[T]]) -> Union[tuple[Any, ...], list[tuple[Any, ...]]]:
def _make_common_data_structure(self, result: T | Sequence[T]) -> tuple[Any, ...] | list[tuple[Any, ...]]:
"""Transform the databricks Row objects into namedtuple."""
# Below ignored lines respect namedtuple docstring, but mypy do not support dynamically
# instantiated namedtuple, and will never do: https://github.com/python/mypy/issues/848
Expand Down

0 comments on commit 90ede99

Please sign in to comment.