Skip to content

feat: client evaluation context getter and setter#610

Open
karnyadavdev wants to merge 2 commits into
open-feature:mainfrom
karnyadavdev:feat-client-evaluation-context-setter
Open

feat: client evaluation context getter and setter#610
karnyadavdev wants to merge 2 commits into
open-feature:mainfrom
karnyadavdev:feat-client-evaluation-context-setter

Conversation

@karnyadavdev
Copy link
Copy Markdown

closes #500

Exposes evaluation_context as a property getter and setter on OpenFeatureClient to support getting and setting a client-wide evaluation context, matching requirements from the OpenFeature specification.

Added a dedicated unit test in tests/test_client.py to verify getting and setting.

@karnyadavdev karnyadavdev requested review from a team as code owners May 30, 2026 19:16
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds getter and setter properties for evaluation_context to the Client class, along with a corresponding unit test. The reviewer suggests updating the setter to default to an empty EvaluationContext if None is passed, which prevents potential type annotation violations and ensures consistency with the class's initialization logic.

Comment thread openfeature/client.py Outdated
Comment on lines +98 to +100
@evaluation_context.setter
def evaluation_context(self, evaluation_context: EvaluationContext) -> None:
self.context = evaluation_context
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent self.context from becoming None (which would violate the EvaluationContext return type annotation of the getter and potentially cause issues for consumers of the client), we should default to an empty EvaluationContext if None is passed to the setter. This also aligns with the initialization logic in __init__.

Suggested change
@evaluation_context.setter
def evaluation_context(self, evaluation_context: EvaluationContext) -> None:
self.context = evaluation_context
@evaluation_context.setter
def evaluation_context(self, evaluation_context: EvaluationContext) -> None:
self.context = evaluation_context or EvaluationContext()

@karnyadavdev karnyadavdev force-pushed the feat-client-evaluation-context-setter branch from 9ac6ddb to 0a96426 Compare May 30, 2026 22:59
Signed-off-by: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com>
Signed-off-by: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com>
@karnyadavdev karnyadavdev reopened this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] client evaluation context support

1 participant