From 3052f80fd617b90e8190b427f265ac879bee2572 Mon Sep 17 00:00:00 2001 From: Richard Nemeth Date: Wed, 13 Jul 2022 17:08:37 +0000 Subject: [PATCH] refactor: no need to try if the type check is performed --- src/keycloak/uma_permissions.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/keycloak/uma_permissions.py b/src/keycloak/uma_permissions.py index 1bf2136..94779f1 100644 --- a/src/keycloak/uma_permissions.py +++ b/src/keycloak/uma_permissions.py @@ -206,13 +206,9 @@ def build_permission_param(permissions): except AttributeError: pass - try: # treat as any other iterable of permissions - result = set() - for permission in permissions: - if not isinstance(permission, (str, UMAPermission)): - raise KeycloakPermissionFormatError("misbuilt permission {}".format(permissions)) - result.add(str(permission)) - return result - except TypeError: - pass - raise KeycloakPermissionFormatError("misbuilt permission {}".format(permissions)) + result = set() + for permission in permissions: + if not isinstance(permission, (str, UMAPermission)): + raise KeycloakPermissionFormatError("misbuilt permission {}".format(permissions)) + result.add(str(permission)) + return result