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_r320423101
##########
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 # noqa
Review comment:
I get this error: [Decorated property not
supported](https://github.com/python/mypy/issues/1362).
The typechecker has a problem with decorated properties for some reason, and
the typechecker only gets run on the file if there is at least one type hint
used or something from `typing` is imported. So, what changed is that there is
now typing in this file.
----------------------------------------------------------------
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]