Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit b4340bb

Browse files
authored
FF-3106 fix: ContextAttributes.from_dict() should not treat bool as numeric (#67)
1 parent 4e88795 commit b4340bb

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

eppo_client/bandit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def from_dict(cls, attributes: Attributes):
5252
numeric_attributes = {
5353
key: float(value)
5454
for key, value in attributes.items()
55-
if isinstance(value, (int, float))
55+
if isinstance(value, (int, float)) and not isinstance(value, bool)
5656
}
5757
categorical_attributes = {
5858
key: to_string(value)

eppo_client/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Note to developers: When ready to bump to 4.0, please change
22
# the `POLL_INTERVAL_SECONDS` constant in `eppo_client/constants.py`
33
# to 30 seconds to match the behavior of the other server SDKs.
4-
__version__ = "3.5.3"
4+
__version__ = "3.5.4"

test/context_attributes_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from eppo_client.bandit import ContextAttributes
2+
3+
4+
def test_from_dict_treats_bools_as_categorical():
5+
attrs = ContextAttributes.from_dict(
6+
{
7+
"categorical": True,
8+
}
9+
)
10+
11+
assert attrs.categorical_attributes == {
12+
"categorical": "true",
13+
}
14+
assert attrs.numeric_attributes == {}

0 commit comments

Comments
 (0)