Skip to content

Commit 6cdb8b6

Browse files
committed
annotate weight for SPLIT reasons
1 parent f970b11 commit 6cdb8b6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

flag_engine/segments/evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ def get_flag_result_from_feature_context(
153153
start_percentage = 0.0
154154

155155
for variant in variants:
156-
limit = variant["weight"] + start_percentage
156+
limit = (weight := variant["weight"]) + start_percentage
157157
if start_percentage <= percentage_value < limit:
158158
return {
159159
"enabled": feature_context["enabled"],
160160
"feature_key": feature_context["feature_key"],
161161
"name": feature_context["name"],
162-
"reason": "SPLIT",
162+
"reason": f"SPLIT; weight={weight}",
163163
"value": variant["value"],
164164
}
165165

tests/unit/segments/test_segments_evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def test_get_evaluation_result__returns_expected(
676676
"enabled": False,
677677
"feature_key": "1",
678678
"name": "my_feature",
679-
"reason": "SPLIT",
679+
"reason": "SPLIT; weight=30",
680680
"value": "foo",
681681
},
682682
),
@@ -686,7 +686,7 @@ def test_get_evaluation_result__returns_expected(
686686
"enabled": False,
687687
"feature_key": "1",
688688
"name": "my_feature",
689-
"reason": "SPLIT",
689+
"reason": "SPLIT; weight=30",
690690
"value": "bar",
691691
},
692692
),

0 commit comments

Comments
 (0)