Skip to content

Commit bcc4629

Browse files
refactor: remove level of nested
1 parent 09f5f79 commit bcc4629

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

openedx_authz/api/decorators.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ def build_filter_from_args(args) -> Filter:
4949
Filter: A Filter object populated with relevant filter values.
5050
"""
5151
filter_obj = Filter()
52-
if filter_on and filter_on in FILTER_DATA_CLASSES:
53-
for arg in args:
54-
if isinstance(arg, FILTER_DATA_CLASSES[filter_on]):
55-
filter_value = getattr(filter_obj, f"v{arg.POLICY_POSITION}")
56-
filter_value.append(arg.policy_template) # Used to load p type policies as well. E.g., lib^*
57-
filter_value.append(arg.namespaced_key) # E.g., lib^lib:DemoX:CSPROB
52+
if not filter_on or filter_on not in FILTER_DATA_CLASSES:
53+
return filter_obj
54+
55+
for arg in args:
56+
if isinstance(arg, FILTER_DATA_CLASSES[filter_on]):
57+
filter_value = getattr(filter_obj, f"v{arg.POLICY_POSITION}")
58+
filter_value.append(arg.policy_template) # Used to load p type policies as well. E.g., lib^*
59+
filter_value.append(arg.namespaced_key) # E.g., lib^lib:DemoX:CSPROB
60+
5861
return filter_obj
5962

6063
def decorator(f):

0 commit comments

Comments
 (0)