11from contextlib import contextmanager , suppress
2- from typing import Any , AnyStr , ClassVar , Iterator , Optional , Sequence , List , Union , Dict
2+ from typing import Any , AnyStr , ClassVar , Iterator , Optional , Sequence , List , Union , Dict , cast
33
44
55from databricks import sql as databricks_lib
@@ -90,7 +90,7 @@ def execute_sql(
9090 @contextmanager
9191 @raise_database_error
9292 def execute_query (self , query : AnyStr , * args : Any , ** kwargs : Any ) -> Iterator [DBApiCursor ]:
93- curr : DBApiCursor = None
93+ curr : DBApiCursor
9494 # TODO: Inline param support will be dropped in future databricks driver, switch to :named paramstyle
9595 # This will drop support for cluster runtime v13.x
9696 # db_args: Optional[Dict[str, Any]]
@@ -110,8 +110,8 @@ def execute_query(self, query: AnyStr, *args: Any, **kwargs: Any) -> Iterator[DB
110110 # db_args = kwargs or None
111111
112112 db_args = args or kwargs or None
113- with self ._conn .cursor () as curr :
114- curr .execute (query , db_args )
113+ with self ._conn .cursor () as curr : # type: ignore[assignment]
114+ curr .execute (cast ( str , query ) , db_args )
115115 yield DBApiCursorImpl (curr ) # type: ignore[abstract]
116116
117117 def fully_qualified_dataset_name (self , escape : bool = True ) -> str :
0 commit comments