uranusjr commented on code in PR #31846:
URL: https://github.com/apache/airflow/pull/31846#discussion_r1227075015


##########
airflow/providers/databricks/hooks/databricks_sql.py:
##########
@@ -138,15 +141,39 @@ def get_conn(self) -> Connection:
             )
         return self._sql_conn
 
+    @overload
+    def run(
+        self,
+        sql: str | Iterable[str],
+        autocommit: bool = False,
+        parameters: Iterable | Mapping | None = None,
+        handler: None = None,
+        split_statements: bool = True,
+        return_last: bool = True,
+    ) -> None:
+        ...
+
+    @overload
+    def run(
+        self,
+        sql: str | Iterable[str],
+        autocommit: bool = False,
+        parameters: Iterable | Mapping | None = None,
+        handler: Callable[[Any], T] = None,  # type: ignore[assignment]
+        split_statements: bool = True,
+        return_last: bool = True,
+    ) -> T | list[T]:

Review Comment:
   I think this can be further split into `Literal[True]` returning `T` and 
`Literal[False]` returning `list[T]`



##########
airflow/providers/databricks/hooks/databricks_sql.py:
##########
@@ -138,15 +141,39 @@ def get_conn(self) -> Connection:
             )
         return self._sql_conn
 
+    @overload
+    def run(
+        self,
+        sql: str | Iterable[str],
+        autocommit: bool = False,
+        parameters: Iterable | Mapping | None = None,
+        handler: None = None,
+        split_statements: bool = True,
+        return_last: bool = True,
+    ) -> None:
+        ...
+
+    @overload
+    def run(
+        self,
+        sql: str | Iterable[str],
+        autocommit: bool = False,
+        parameters: Iterable | Mapping | None = None,
+        handler: Callable[[Any], T] = None,  # type: ignore[assignment]

Review Comment:
   ```suggestion
           handler: Callable[[Any], T] | None = None,
   ```
   
   I don’t think `handler` is required for this signature…?



##########
airflow/providers/databricks/hooks/databricks_sql.py:
##########
@@ -138,15 +141,39 @@ def get_conn(self) -> Connection:
             )
         return self._sql_conn
 
+    @overload

Review Comment:
   I’m not quite sure how Mypy handles this; what happens if we omit `overload` 
signatures in subclasses? Do they get shadowed completely?



##########
airflow/providers/databricks/hooks/databricks_sql.py:
##########
@@ -138,15 +141,39 @@ def get_conn(self) -> Connection:
             )
         return self._sql_conn
 
+    @overload
+    def run(
+        self,
+        sql: str | Iterable[str],
+        autocommit: bool = False,
+        parameters: Iterable | Mapping | None = None,
+        handler: None = None,
+        split_statements: bool = True,
+        return_last: bool = True,
+    ) -> None:
+        ...
+
+    @overload
+    def run(
+        self,
+        sql: str | Iterable[str],
+        autocommit: bool = False,
+        parameters: Iterable | Mapping | None = None,

Review Comment:
   I think the mapping case must have str keys, so `Mapping[str, Any]`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to