Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move flag evaluation details to a dataclass #27

Merged
merged 6 commits into from
Oct 18, 2022
23 changes: 10 additions & 13 deletions open_feature/flag_evaluation/flag_evaluation_details.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import typing
from dataclasses import dataclass

from open_feature.flag_evaluation.error_code import ErrorCode
from open_feature.flag_evaluation.reason import Reason


@dataclass
class FlagEvaluationDetails:
def __init__(
self,
key: str,
value,
reason: Reason,
error_code: ErrorCode = None,
variant=None,
):
self.key = key
self.value = value
self.reason = reason
self.error_code = error_code
self.variant = variant
flag_key: str
value: typing.Any
variant: str = None
reason: Reason = None
error_code: ErrorCode = None
error_message: str = None
8 changes: 4 additions & 4 deletions open_feature/provider/no_op_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_boolean_details(
evaluation_context: EvaluationContext = None,
):
return FlagEvaluationDetails(
key=key,
flag_key=key,
ajhelsby marked this conversation as resolved.
Show resolved Hide resolved
value=default_value,
reason=Reason.DEFAULT,
variant=PASSED_IN_DEFAULT,
Expand All @@ -32,7 +32,7 @@ def get_string_details(
evaluation_context: EvaluationContext = None,
):
return FlagEvaluationDetails(
key=key,
flag_key=key,
value=default_value,
reason=Reason.DEFAULT,
variant=PASSED_IN_DEFAULT,
Expand All @@ -45,7 +45,7 @@ def get_number_details(
evaluation_context: EvaluationContext = None,
):
return FlagEvaluationDetails(
key=key,
flag_key=key,
value=default_value,
reason=Reason.DEFAULT,
variant=PASSED_IN_DEFAULT,
Expand All @@ -58,7 +58,7 @@ def get_object_details(
evaluation_context: EvaluationContext = None,
):
return FlagEvaluationDetails(
key=key,
flag_key=key,
value=default_value,
reason=Reason.DEFAULT,
variant=PASSED_IN_DEFAULT,
Expand Down