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



##########
File path: superset/utils/core.py
##########
@@ -985,11 +988,11 @@ def is_adhoc_metric(metric) -> bool:
     )
 
 
-def get_metric_name(metric):
-    return metric["label"] if is_adhoc_metric(metric) else metric
+def get_metric_name(metric: Metric) -> str:

Review comment:
       @villebro the code works if the `metric` is `None` (this can happen when 
a key exists in the form-data but the value is `None`) even though the `Metric` 
type is explicitly `Union[Dict[str, str], str]`. Generally I think we should 
strive to ensure only valid inputs are provided to functions (otherwise the 
logic can get quite complex), i.e., I prefer, 
   
   ```python
   if metric:
       name = get_metric_name(metric)
       ...
   ```
   
   rather than, 
   
   ```python
   name = get_metric_name(metric)
   
   if name:
      ...
   ```




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



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

Reply via email to