[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-09-03 Thread GitBox
etr2460 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_r320497728
 
 

 ##
 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:
   Got it, can we add this comment instead then to only block certain linting 
and not all of it on this line? `# type: ignore`


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-09-03 Thread GitBox
etr2460 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_r320382172
 
 

 ##
 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:
   what changed here requiring the `noqa` comment?


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-09-03 Thread GitBox
etr2460 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_r320381394
 
 

 ##
 File path: superset/connectors/base/models.py
 ##
 @@ -60,8 +60,8 @@ class BaseDatasource(AuditMixinNullable, ImportMixin):
 perm = Column(String(1000))
 
 sql = None
-owners = None
 
 Review comment:
   What's the implication of removing this default value?


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-08-29 Thread GitBox
etr2460 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_r319264510
 
 

 ##
 File path: superset/common/query_object.py
 ##
 @@ -34,12 +35,28 @@ class QueryObject:
 and druid. The query objects are constructed on the client.
 """
 
+granularity: str
+from_dttm: datetime
+to_dttm: datetime
+is_timeseries: bool
+time_shift: timedelta
+groupby: List[str]
+metrics: List[Union[Dict, str]]
+row_limit: int
+filter: List[str]
+timeseries_limit: int
+timeseries_limit_metric: Optional[Dict]
+order_desc: bool
+extras: Dict
+columns: List[str]
+orderby: List[List]
+
 def __init__(
 self,
 granularity: str,
 metrics: List[Union[Dict, str]],
-groupby: List[str] = None,
-filters: List[str] = None,
+groupby: Optional[List[str]] = None,
 
 Review comment:
   that's horrible... I'm going to go back to javascript and never return


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-08-28 Thread GitBox
etr2460 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_r318843869
 
 

 ##
 File path: superset/connectors/sqla/models.py
 ##
 @@ -1061,12 +1078,39 @@ def query_datasources_by_name(cls, session, database, 
datasource_name, schema=No
 return query.all()
 
 @staticmethod
-def default_query(qry):
+def default_query(qry) -> Query:
 return qry.filter_by(is_sqllab_view=False)
 
+def has_extra_cache_keys(self, query_obj: Dict) -> bool:
 
 Review comment:
   Looks like you need to rebase off of master so this doesn't show up as a 
change


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-08-28 Thread GitBox
etr2460 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_r318841105
 
 

 ##
 File path: superset/common/query_context.py
 ##
 @@ -109,17 +114,17 @@ def get_query_result(self, query_object):
 "df": df,
 }
 
-def df_metrics_to_num(self, df, query_object):
+def df_metrics_to_num(self, df: pd.DataFrame, query_object: QueryObject) 
-> None:
 """Converting metrics to numeric when pandas.read_sql cannot"""
 metrics = [metric for metric in query_object.metrics]
 for col, dtype in df.dtypes.items():
 if dtype.type == np.object_ and col in metrics:
 df[col] = pd.to_numeric(df[col], errors="coerce")
 
-def get_data(self, df):
+def get_data(self, df: pd.DataFrame) -> List[Dict]:
 
 Review comment:
   `df.to_dict` returns a list of dictionaries? Not doubting you, but want to 
make sure this is actually correct, because it doesn't seem obvious to me at all


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-08-28 Thread GitBox
etr2460 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_r318842141
 
 

 ##
 File path: superset/common/query_object.py
 ##
 @@ -34,12 +35,28 @@ class QueryObject:
 and druid. The query objects are constructed on the client.
 """
 
+granularity: str
+from_dttm: datetime
+to_dttm: datetime
+is_timeseries: bool
+time_shift: timedelta
+groupby: List[str]
+metrics: List[Union[Dict, str]]
+row_limit: int
+filter: List[str]
+timeseries_limit: int
+timeseries_limit_metric: Optional[Dict]
+order_desc: bool
+extras: Dict
+columns: List[str]
+orderby: List[List]
+
 def __init__(
 self,
 granularity: str,
 metrics: List[Union[Dict, str]],
-groupby: List[str] = None,
-filters: List[str] = None,
+groupby: Optional[List[str]] = None,
 
 Review comment:
   I think this should default groupby to [] instead of None, that way we can 
remove the `Optional` here and the logic on line 83. we should do the same for 
filters, columns, and orderby too


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-08-28 Thread GitBox
etr2460 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_r318842584
 
 

 ##
 File path: superset/connectors/base/models.py
 ##
 @@ -154,11 +154,11 @@ def short_data(self):
 }
 
 @property
-def select_star(self):
+def select_star(self) -> str:
 
 Review comment:
   This should be `Optional[str]` right? if not then it should probably raise a 
`NotImplementedError()`


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:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [incubator-superset] etr2460 commented on a change in pull request #8138: [typing] add typing for superset/connectors and superset/common

2019-08-28 Thread GitBox
etr2460 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_r318840944
 
 

 ##
 File path: superset/common/query_context.py
 ##
 @@ -150,8 +155,8 @@ def cache_timeout(self):
 return self.datasource.database.cache_timeout
 return config.get("CACHE_DEFAULT_TIMEOUT")
 
 Review comment:
   either you need to add a default value to the `get` call or return 
`config["CACHE_DEFAULT_TIMEOUT"]` otherwise this could return None


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:
us...@infra.apache.org


With regards,
Apache Git Services

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