serenajiang commented on a change in pull request #9224: refactor copy 
filter_scopes and add tests
URL: 
https://github.com/apache/incubator-superset/pull/9224#discussion_r385929111
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -1233,20 +1218,16 @@ def save_dash(self, dashboard_id):
         dash = session.query(Dashboard).get(dashboard_id)
         check_ownership(dash, raise_if_false=True)
         data = json.loads(request.form.get("data"))
-        if "filter_scopes" in data:
-            new_filter_scopes = copy_filter_scopes(
-                old_to_new_slc_id_dict={slc.id: slc.id for slc in dash.slices},
-                old_filter_scopes=json.loads(data["filter_scopes"] or "{}"),
-            )
-            data["filter_scopes"] = json.dumps(new_filter_scopes)
         self._set_dash_metadata(dash, data)
         session.merge(dash)
         session.commit()
         session.close()
         return json_success(json.dumps({"status": "SUCCESS"}))
 
     @staticmethod
-    def _set_dash_metadata(dashboard, data):
+    def _set_dash_metadata(
+        dashboard, data, old_to_new_sliceids: Dict[int, int] = {}
 
 Review comment:
   While it probably isn't an issue here since you aren't mutating it, should 
change `old_to_new_sliceids` to default to `None` instead of `{}`. At the 
beginning of the function, add a line like
   ```python
   old_to_new_sliceids = old_to_new_sliceids or {}
   ```
   
   Python doesn't deal well with default mutable arguments:
   ```python
   def f(d = {}):
       return d
   
   dict1 = f()
   dict1["x"] = "hi"
   dict2 = f()
   print(dict2["x"]) # prints "hi"
   ```
   
   

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