From df46c2499e59dc4db994c335e9759e79753c5c02 Mon Sep 17 00:00:00 2001 From: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com> Date: Sun, 31 May 2026 04:29:26 +0530 Subject: [PATCH 1/2] feat: add client evaluation context getter and setter Signed-off-by: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com> --- openfeature/client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openfeature/client.py b/openfeature/client.py index 95dc5b6d..aa5e3594 100644 --- a/openfeature/client.py +++ b/openfeature/client.py @@ -91,6 +91,14 @@ def __init__( def provider(self) -> FeatureProvider: return provider_registry.get_provider(self.domain) + @property + def evaluation_context(self) -> EvaluationContext: + return self.context + + @evaluation_context.setter + def evaluation_context(self, evaluation_context: EvaluationContext | None) -> None: + self.context = evaluation_context or EvaluationContext() + def get_provider_status(self) -> ProviderStatus: return provider_registry.get_provider_status(self.provider) From 966844265da8916bda605e42764e7536915a81a5 Mon Sep 17 00:00:00 2001 From: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com> Date: Sun, 31 May 2026 04:29:27 +0530 Subject: [PATCH 2/2] test: add client evaluation context getter and setter test Signed-off-by: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com> --- tests/test_client.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index 63453c99..cf5631bf 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -760,3 +760,29 @@ def test_should_noop_if_provider_does_not_support_tracking(monkeypatch): set_provider(provider) client = get_client() client.track(tracking_event_name="test") + + +def test_client_should_allow_getting_and_setting_evaluation_context(): + # Given + client = get_client() + initial_context = client.evaluation_context + assert isinstance(initial_context, EvaluationContext) + + new_context = EvaluationContext( + targeting_key="user_123", attributes={"beta_user": True} + ) + + # When + client.evaluation_context = new_context + + # Then + assert client.evaluation_context == new_context + assert client.context == new_context + + # When setting to None (resetting) + client.evaluation_context = None + + # Then it should default to an empty EvaluationContext + assert isinstance(client.evaluation_context, EvaluationContext) + assert client.evaluation_context.targeting_key is None + assert not client.evaluation_context.attributes