From 80c6ecc421fe4dcc160dfc79ec5e3882796118da Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Fri, 21 Apr 2023 13:44:36 -0500 Subject: [PATCH] fix(federation): follow-up This mainly was intended to clean up confusing comments, and to add @staticmethod since we're at it. Related-Change-Id: I665b7e0234650ba07e0d030a2d442d6599d0888a Change-Id: I7cd62cdd188da77367820317f4875b48a247ff00 --- keystone/federation/utils.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/keystone/federation/utils.py b/keystone/federation/utils.py index 71e6318a41..f6f35a8379 100644 --- a/keystone/federation/utils.py +++ b/keystone/federation/utils.py @@ -562,22 +562,16 @@ class RuleProcessor(object): LOG.debug('mapped_properties: %s', mapped_properties) return mapped_properties - def _ast_literal_eval(self, value): - # This is a workaround for the fact that ast.literal_eval handles the - # case of either a string or a list of strings, but not a potential - # list of ints. - + @staticmethod + def _ast_literal_eval(value): try: values = ast.literal_eval(value) - # NOTE(mnaser): It's possible that the group_names_list is a - # numerical value which would successfully parse - # and not raise an exception, so we forcefully - # raise is here. + # We expect a list here, but literal_eval will successfully + # parse and return a single value. We raise ValueError if so. if not isinstance(values, list): raise ValueError except (ValueError, SyntaxError): values = [value] - return values def _normalize_groups(self, identity_value):