villebro commented on a change in pull request #7643: 7620: Start removing 
dependencies on requests
URL: 
https://github.com/apache/incubator-superset/pull/7643#discussion_r298260635
 
 

 ##########
 File path: superset/utils/core.py
 ##########
 @@ -178,18 +181,21 @@ def string_to_num(s: str):
         return None
 
 
-class DimSelector(Having):
-    def __init__(self, **args):
-        # Just a hack to prevent any exceptions
-        Having.__init__(self, type="equalTo", aggregation=None, value=None)
+try:
+    class DimSelector(Having):
+        def __init__(self, **args):
+            # Just a hack to prevent any exceptions
+            Having.__init__(self, type='equalTo', aggregation=None, value=None)
 
-        self.having = {
-            "having": {
-                "type": "dimSelector",
-                "dimension": args["dimension"],
-                "value": args["value"],
+            self.having = {
+                'having': {
+                    'type': 'dimSelector',
+                    'dimension': args['dimension'],
+                    'value': args['value'],
+                },
             }
-        }
+except NameError:
+    pass
 
 Review comment:
   For clarity, it might be better to have this try-except block done together 
with the import, i.e. first trying to import `Having`, and if that's found, 
continue with defining `DimSelector`. Right now they are quite far apart, and 
makes understanding the optionality slightly less obvious.

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