Skip to content

Commit 8f10c42

Browse files
Copilotkhvn26
andcommitted
fix: improve context filtering to be more robust and type-safe
Co-authored-by: khvn26 <[email protected]>
1 parent 13904f6 commit 8f10c42

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

flagsmith/flagsmith.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,14 @@ def _get_environment_flags_from_document(self) -> Flags:
334334

335335
# Omit segments from evaluation context for environment flags
336336
# as they are only relevant for identity-specific evaluations
337-
context_without_segments: SDKEvaluationContext = {
338-
"environment": self._evaluation_context["environment"],
339-
"features": self._evaluation_context.get("features", {}),
340-
}
337+
context_without_segments = typing.cast(
338+
SDKEvaluationContext,
339+
{
340+
key: value
341+
for key, value in self._evaluation_context.items()
342+
if key != "segments"
343+
},
344+
)
341345

342346
evaluation_result = engine.get_evaluation_result(context_without_segments)
343347

0 commit comments

Comments
 (0)