john-bodley commented on a change in pull request #9213: [fix] remove chart id 
from filter_scopes metadata if chart is not in dash anymore
URL: 
https://github.com/apache/incubator-superset/pull/9213#discussion_r384815514
 
 

 ##########
 File path: superset/utils/dashboard_filter_scopes_converter.py
 ##########
 @@ -77,10 +77,13 @@ def copy_filter_scopes(
 ) -> Dict:
     new_filter_scopes = {}
     for (slice_id, scopes) in old_filter_scopes.items():
-        new_filter_key = old_to_new_slc_id_dict[int(slice_id)]
-        new_filter_scopes[str(new_filter_key)] = scopes
-        for scope in scopes.values():
-            scope["immune"] = [
-                old_to_new_slc_id_dict[slice_id] for slice_id in 
scope.get("immune")
-            ]
+        new_filter_key = old_to_new_slc_id_dict.get(int(slice_id))
+        if new_filter_key:
+            new_filter_scopes[str(new_filter_key)] = scopes
+            for scope in scopes.values():
+                scope["immune"] = [
+                    old_to_new_slc_id_dict[slice_id]
+                    for slice_id in scope.get("immune")
+                    if old_to_new_slc_id_dict.get(slice_id) is not None
 
 Review comment:
   Can the value of `old_to_new_slc_id_dict` be `None` for an existing key? If 
not I think having, 
   
   ```python
   if slice_id in old_to_new_slc_id_dict
   ```
   
   would be clearer. Also on line 80 the logic is `get(int(slice_id))` whereas 
here it's `get(slice_id)`. 
   

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