feat: client evaluation context getter and setter#610
Conversation
There was a problem hiding this comment.
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.
| @evaluation_context.setter | ||
| def evaluation_context(self, evaluation_context: EvaluationContext) -> None: | ||
| self.context = evaluation_context |
There was a problem hiding this comment.
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__.
| @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() |
9ac6ddb to
0a96426
Compare
Signed-off-by: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com>
Signed-off-by: Karan Yadav <47368518+karnyadavdev@users.noreply.github.com>
closes #500
Exposes
evaluation_contextas a property getter and setter onOpenFeatureClientto support getting and setting a client-wide evaluation context, matching requirements from the OpenFeature specification.Added a dedicated unit test in
tests/test_client.pyto verify getting and setting.