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 2021/08/11 19:36:21 UTC

[GitHub] [superset] serenajiang commented on a change in pull request #16194: fix(viz): deduce metric name if empty

serenajiang commented on a change in pull request #16194:
URL: https://github.com/apache/superset/pull/16194#discussion_r687118410



##########
File path: superset/utils/core.py
##########
@@ -1273,7 +1280,33 @@ def is_adhoc_metric(metric: Metric) -> bool:
 
 
 def get_metric_name(metric: Metric) -> str:
-    return metric["label"] if is_adhoc_metric(metric) else metric  # type: ignore
+    """
+    Extract label from metric
+
+    :param metric: object to extract label from
+    :return: String representation of metric
+    :raises ValueError: if metric object is invalid
+    """
+    if is_adhoc_metric(metric):

Review comment:
       Could we make `is_adhoc_metric` a [type guard](https://www.python.org/dev/peps/pep-0647/) so that we don't need to use `cast` and `# type: ignore` so much? It's available in [typing_extensions](https://github.com/python/typing/blob/master/typing_extensions/README.rst).




-- 
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: notifications-unsubscribe@superset.apache.org

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