Skip to content

Commit f45e0a2

Browse files
committed
improve readability
1 parent 4ff0251 commit f45e0a2

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

flag_engine/engine.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ def get_environment_feature_state(
5151
"`get_environment_feature_state` is deprecated, use `get_evaluation_result` instead.",
5252
DeprecationWarning,
5353
)
54-
try:
55-
return next(
56-
filter(lambda f: f.feature.name == feature_name, environment.feature_states)
57-
)
5854

59-
except StopIteration:
60-
raise FeatureStateNotFound()
55+
for feature_state in environment.feature_states:
56+
if feature_state.feature.name == feature_name:
57+
return feature_state
58+
59+
raise FeatureStateNotFound()
6160

6261

6362
def get_identity_feature_states(
@@ -121,17 +120,8 @@ def get_identity_feature_state(
121120

122121
result = get_evaluation_result(context)
123122

124-
feature_states = map_flag_results_to_feature_states(result["flags"])
125-
126-
matching_feature_state = next(
127-
filter(
128-
lambda feature_state: feature_state.feature.name == feature_name,
129-
feature_states,
130-
),
131-
None,
132-
)
133-
134-
if not matching_feature_state:
135-
raise FeatureStateNotFound()
123+
for feature_state in map_flag_results_to_feature_states(result["flags"]):
124+
if feature_state.feature.name == feature_name:
125+
return feature_state
136126

137-
return matching_feature_state
127+
raise FeatureStateNotFound()

0 commit comments

Comments
 (0)