diff --git a/eppo_client/bandit.py b/eppo_client/bandit.py index 8f9be69..264d375 100644 --- a/eppo_client/bandit.py +++ b/eppo_client/bandit.py @@ -52,7 +52,7 @@ def from_dict(cls, attributes: Attributes): numeric_attributes = { key: float(value) for key, value in attributes.items() - if isinstance(value, (int, float)) + if isinstance(value, (int, float)) and not isinstance(value, bool) } categorical_attributes = { key: to_string(value) diff --git a/eppo_client/version.py b/eppo_client/version.py index 5b94c7d..6cbec38 100644 --- a/eppo_client/version.py +++ b/eppo_client/version.py @@ -1,4 +1,4 @@ # Note to developers: When ready to bump to 4.0, please change # the `POLL_INTERVAL_SECONDS` constant in `eppo_client/constants.py` # to 30 seconds to match the behavior of the other server SDKs. -__version__ = "3.5.3" +__version__ = "3.5.4" diff --git a/test/context_attributes_test.py b/test/context_attributes_test.py new file mode 100644 index 0000000..8cab43c --- /dev/null +++ b/test/context_attributes_test.py @@ -0,0 +1,14 @@ +from eppo_client.bandit import ContextAttributes + + +def test_from_dict_treats_bools_as_categorical(): + attrs = ContextAttributes.from_dict( + { + "categorical": True, + } + ) + + assert attrs.categorical_attributes == { + "categorical": "true", + } + assert attrs.numeric_attributes == {}