Skip to content

Commit 4f62b49

Browse files
committed
refactor: flat is better than nested
1 parent a08d5c0 commit 4f62b49

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

scim2_server/operators.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,43 +103,43 @@ def __call__(self, model: BaseModel):
103103
if not self.path:
104104
self.call_on_root(model)
105105
return self.do_return()
106-
else:
107-
model, path = self.parse_path(model)
108106

109-
match path:
110-
case {
111-
"attribute": attribute,
112-
"condition": None,
113-
"sub_attribute": None,
114-
}:
115-
self.match_attribute(attribute, model)
116-
return self.do_return()
117-
case {
118-
"attribute": attribute,
119-
"condition": None,
120-
"sub_attribute": sub_path,
121-
}:
122-
self.match_complex_attribute(attribute, model, sub_path)
123-
return self.do_return()
124-
case {
125-
"attribute": attribute,
126-
"condition": condition,
127-
"sub_attribute": None,
128-
}:
129-
self.match_multi_valued_attribute(attribute, condition, model)
130-
return self.do_return()
131-
case {
132-
"attribute": attribute,
133-
"condition": condition,
134-
"sub_attribute": sub_attribute,
135-
}:
136-
self.match_multi_valued_attribute_sub(
137-
attribute, condition, model, sub_attribute
138-
)
139-
return self.do_return()
140-
case _:
141-
self.call_on_root(model)
142-
return self.do_return()
107+
model, path = self.parse_path(model)
108+
109+
match path:
110+
case {
111+
"attribute": attribute,
112+
"condition": None,
113+
"sub_attribute": None,
114+
}:
115+
self.match_attribute(attribute, model)
116+
return self.do_return()
117+
case {
118+
"attribute": attribute,
119+
"condition": None,
120+
"sub_attribute": sub_path,
121+
}:
122+
self.match_complex_attribute(attribute, model, sub_path)
123+
return self.do_return()
124+
case {
125+
"attribute": attribute,
126+
"condition": condition,
127+
"sub_attribute": None,
128+
}:
129+
self.match_multi_valued_attribute(attribute, condition, model)
130+
return self.do_return()
131+
case {
132+
"attribute": attribute,
133+
"condition": condition,
134+
"sub_attribute": sub_attribute,
135+
}:
136+
self.match_multi_valued_attribute_sub(
137+
attribute, condition, model, sub_attribute
138+
)
139+
return self.do_return()
140+
case _:
141+
self.call_on_root(model)
142+
return self.do_return()
143143

144144
def match_multi_valued_attribute_sub(
145145
self, attribute: str, condition: str, model: BaseModel, sub_attribute: str

0 commit comments

Comments
 (0)