From a169b6071209c4f6681c95486127fc43884ff6d1 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Wed, 22 Jun 2022 18:28:59 -0300 Subject: [PATCH] fix: Changes the return type of get_permissions to be JSON friendly (#20472) * fix: Changes the return type of get_permissions to be JSON friendly * Removes dangling comma * Removes unused import * Fixes typing errors --- superset/views/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/superset/views/utils.py b/superset/views/utils.py index 719642ef13a96..94f595ce18aab 100644 --- a/superset/views/utils.py +++ b/superset/views/utils.py @@ -17,7 +17,7 @@ import logging from collections import defaultdict from functools import wraps -from typing import Any, Callable, DefaultDict, Dict, List, Optional, Set, Tuple, Union +from typing import Any, Callable, DefaultDict, Dict, List, Optional, Tuple, Union from urllib import parse import msgpack @@ -103,7 +103,7 @@ def bootstrap_user_data(user: User, include_perms: bool = False) -> Dict[str, An def get_permissions( user: User, -) -> Tuple[Dict[str, List[List[str]]], DefaultDict[str, Set[str]]]: +) -> Tuple[Dict[str, List[List[str]]], DefaultDict[str, List[str]]]: if not user.roles: raise AttributeError("User object does not have roles") @@ -116,8 +116,10 @@ def get_permissions( if permission[0] in ("datasource_access", "database_access"): permissions[permission[0]].add(permission[1]) roles[role.name].append([permission[0], permission[1]]) - - return roles, permissions + transformed_permissions = defaultdict(list) + for perm in permissions: + transformed_permissions[perm] = list(permissions[perm]) + return roles, transformed_permissions def get_viz(