Skip to content

Commit 1f5950e

Browse files
committed
prioritise traits
1 parent c569710 commit 1f5950e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

flag_engine/segments/evaluator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ def _get_context_value_getter(
385385
return partial(_get_trait_value, trait_key=property)
386386

387387
def getter(context: EvaluationContext[SegmentMetadataT]) -> ContextValue:
388+
value: object
389+
if (value := _get_trait_value(context, property)) is not None:
390+
return value
388391
if typing.TYPE_CHECKING: # pragma: no cover
389392
# Ugly hack to satisfy mypy :(
390393
data = dict(context)
@@ -394,8 +397,6 @@ def getter(context: EvaluationContext[SegmentMetadataT]) -> ContextValue:
394397
if result := compiled_query.find_one(data):
395398
if is_context_value(value := result.value):
396399
return value
397-
else:
398-
return _get_trait_value(context, property)
399400
return None
400401
except jsonpath_rfc9535.JSONPathError: # pragma: no cover
401402
# This is supposed to be unreachable, but if it happens,

0 commit comments

Comments
 (0)