You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/05/27 03:30:07 UTC

[GitHub] [incubator-superset] john-bodley commented on a change in pull request #9824: style(mypy): enforcing mypy typing for superset.connectors

john-bodley commented on a change in pull request #9824:
URL: https://github.com/apache/incubator-superset/pull/9824#discussion_r430038941



##########
File path: superset/typing.py
##########
@@ -16,15 +16,31 @@
 # under the License.
 from typing import Any, Callable, Dict, List, Optional, Tuple, Union
 
-from flask import Flask
+import flask
+import werkzeug
 from flask_caching import Cache
 
-CacheConfig = Union[Callable[[Flask], Cache], Dict[str, Any]]
+CacheConfig = Union[Callable[[flask.Flask], Cache], Dict[str, Any]]
 DbapiDescriptionRow = Tuple[
     str, str, Optional[str], Optional[str], Optional[int], Optional[int], bool
 ]
 DbapiDescription = Union[List[DbapiDescriptionRow], Tuple[DbapiDescriptionRow, ...]]
 DbapiResult = List[Union[List[Any], Tuple[Any, ...]]]
 FilterValue = Union[float, int, str]
 FilterValues = Union[FilterValue, List[FilterValue], Tuple[FilterValue]]
+Granularity = Union[str, Dict[str, Union[str, float]]]
+Metric = Union[Dict[str, str], str]
+QueryObjectDict = Dict[str, Any]
 VizData = Optional[Union[List[Any], Dict[Any, Any]]]
+
+# Flask response.
+Base = Union[bytes, str]
+Status = Union[int, str]
+Headers = Dict[str, Any]
+FlaskResponse = Union[
+    flask.wrappers.Response,
+    werkzeug.wrappers.Response,
+    Base,
+    Union[Base, Status],
+    Union[Base, Status, Headers],
+]

Review comment:
       @villebro, that's actually a typo as the later `Union` should be a `Tuple` and given that `flask.wrappers.Response` is derived from `werkzeug.wrappers.Response` per [here](https://github.com/pallets/flask/blob/master/src/flask/wrappers.py#L93) this could be:
   
   ```python
   FlaskResponse = Union[
       werkzeug.wrappers.Response,
       Base,
       Tuple[Base, Status],
       Tuple[Base, Status, Headers],
   ]
   ```
   

##########
File path: superset/typing.py
##########
@@ -16,15 +16,31 @@
 # under the License.
 from typing import Any, Callable, Dict, List, Optional, Tuple, Union
 
-from flask import Flask
+import flask
+import werkzeug
 from flask_caching import Cache
 
-CacheConfig = Union[Callable[[Flask], Cache], Dict[str, Any]]
+CacheConfig = Union[Callable[[flask.Flask], Cache], Dict[str, Any]]
 DbapiDescriptionRow = Tuple[
     str, str, Optional[str], Optional[str], Optional[int], Optional[int], bool
 ]
 DbapiDescription = Union[List[DbapiDescriptionRow], Tuple[DbapiDescriptionRow, ...]]
 DbapiResult = List[Union[List[Any], Tuple[Any, ...]]]
 FilterValue = Union[float, int, str]
 FilterValues = Union[FilterValue, List[FilterValue], Tuple[FilterValue]]
+Granularity = Union[str, Dict[str, Union[str, float]]]
+Metric = Union[Dict[str, str], str]
+QueryObjectDict = Dict[str, Any]
 VizData = Optional[Union[List[Any], Dict[Any, Any]]]
+
+# Flask response.
+Base = Union[bytes, str]
+Status = Union[int, str]
+Headers = Dict[str, Any]
+FlaskResponse = Union[
+    flask.wrappers.Response,
+    werkzeug.wrappers.Response,
+    Base,
+    Union[Base, Status],
+    Union[Base, Status, Headers],
+]

Review comment:
       @villebro, that's actually a typo as the later `Union` should be a `Tuple`. Also given that `flask.wrappers.Response` is derived from `werkzeug.wrappers.Response` per [here](https://github.com/pallets/flask/blob/master/src/flask/wrappers.py#L93) this could be:
   
   ```python
   FlaskResponse = Union[
       werkzeug.wrappers.Response,
       Base,
       Tuple[Base, Status],
       Tuple[Base, Status, Headers],
   ]
   ```
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org