serenajiang commented on a change in pull request #8138: [typing] add typing 
for superset/connectors and superset/common
URL: 
https://github.com/apache/incubator-superset/pull/8138#discussion_r321495974
 
 

 ##########
 File path: superset/connectors/druid/models.py
 ##########
 @@ -146,53 +151,53 @@ def __html__(self):
         return self.__repr__()
 
     @property
-    def data(self):
+    def data(self) -> Dict:
         return {"id": self.id, "name": self.cluster_name, "backend": "druid"}
 
     @staticmethod
-    def get_base_url(host, port):
+    def get_base_url(host, port) -> str:
         if not re.match("http(s)?://", host):
             host = "http://"; + host
 
         url = "{0}:{1}".format(host, port) if port else host
         return url
 
-    def get_base_broker_url(self):
+    def get_base_broker_url(self) -> str:
         base_url = self.get_base_url(self.broker_host, self.broker_port)
         return f"{base_url}/{self.broker_endpoint}"
 
-    def get_pydruid_client(self):
+    def get_pydruid_client(self) -> PyDruid:
         cli = PyDruid(
             self.get_base_url(self.broker_host, self.broker_port), 
self.broker_endpoint
         )
         if self.broker_user and self.broker_pass:
             cli.set_basic_auth_credentials(self.broker_user, self.broker_pass)
         return cli
 
-    def get_datasources(self):
+    def get_datasources(self) -> List[Dict]:
         endpoint = self.get_base_broker_url() + "/datasources"
         auth = requests.auth.HTTPBasicAuth(self.broker_user, self.broker_pass)
         return json.loads(requests.get(endpoint, auth=auth).text)
 
-    def get_druid_version(self):
+    def get_druid_version(self) -> str:
         endpoint = self.get_base_url(self.broker_host, self.broker_port) + 
"/status"
         auth = requests.auth.HTTPBasicAuth(self.broker_user, self.broker_pass)
         return json.loads(requests.get(endpoint, auth=auth).text)["version"]
 
-    @property
+    @property  # type: ignore
     @utils.memoized
-    def druid_version(self):
+    def druid_version(self) -> str:
         return self.get_druid_version()
 
     def refresh_datasources(
-        self, datasource_name=None, merge_flag=True, refreshAll=True
-    ):
+        self, datasource_name=None, merge_flag: bool = True, refreshAll: bool 
= True
+    ) -> None:
         """Refresh metadata of all datasources in the cluster
         If ``datasource_name`` is specified, only that datasource is updated
         """
         ds_list = self.get_datasources()
         blacklist = conf.get("DRUID_DATA_SOURCE_BLACKLIST", [])
-        ds_refresh = []
+        ds_refresh = []  # type: ignore
 
 Review comment:
   The typechecker demands a type for `ds_refresh` since `ds_list` now has the 
type assigned by `get_datasources()`.
   
   But now I'm a little sketched out about the type I assigned for 
`get_datasources()`. Can you take a look? I thought `get_datasources` returned 
`List[Dict]` because of `/datasources/`, but now I'm wondering if it might be 
`List[str]`.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to