Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion providers/openfeature-provider-env-var/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "OpenFeature Python Environment Variable Provider"
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"openfeature-sdk>=0.6.0",
"openfeature-sdk>=0.8.2",
]
authors = [{ name = "OpenFeature", email = "[email protected]" }]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from openfeature.evaluation_context import EvaluationContext
from openfeature.exception import FlagNotFoundError, ParseError
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
from openfeature.flag_evaluation import FlagResolutionDetails, FlagValueType, Reason
from openfeature.provider import AbstractProvider, Metadata


Expand Down Expand Up @@ -64,9 +64,13 @@ def resolve_float_details(
def resolve_object_details(
self,
flag_key: str,
default_value: typing.Union[dict, list],
default_value: typing.Union[
typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]
],
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[typing.Union[dict, list]]:
) -> FlagResolutionDetails[
typing.Union[typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]]
]:
def parse(value: str) -> typing.Union[dict, list]:
result = json.loads(value)

Expand Down
280 changes: 140 additions & 140 deletions providers/openfeature-provider-env-var/uv.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion providers/openfeature-provider-flagd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
]
keywords = []
dependencies = [
"openfeature-sdk>=0.6.0",
"openfeature-sdk>=0.8.2",
"grpcio>=1.68.1",
"protobuf>=5.26.1",
"mmh3>=4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from openfeature.evaluation_context import EvaluationContext
from openfeature.event import ProviderEventDetails
from openfeature.flag_evaluation import FlagResolutionDetails
from openfeature.flag_evaluation import FlagResolutionDetails, FlagValueType
from openfeature.hook import Hook
from openfeature.provider import AbstractProvider
from openfeature.provider.metadata import Metadata
Expand Down Expand Up @@ -199,9 +199,13 @@ def resolve_integer_details(
def resolve_object_details(
self,
flag_key: str,
default_value: typing.Union[dict, list],
default_value: typing.Union[
typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]
],
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[typing.Union[dict, list]]:
) -> FlagResolutionDetails[
typing.Union[typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]]
]:
return self.resolver.resolve_object_details(
flag_key, default_value, evaluation_context
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ProviderNotReadyError,
TypeMismatchError,
)
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
from openfeature.flag_evaluation import FlagResolutionDetails, FlagValueType, Reason
from openfeature.schemas.protobuf.flagd.evaluation.v1 import (
evaluation_pb2,
evaluation_pb2_grpc,
Expand Down Expand Up @@ -300,9 +300,13 @@ def resolve_integer_details(
def resolve_object_details(
self,
key: str,
default_value: typing.Union[dict, list],
default_value: typing.Union[
typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]
],
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[typing.Union[dict, list]]:
) -> FlagResolutionDetails[
typing.Union[typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]]
]:
return self._resolve(key, FlagType.OBJECT, default_value, evaluation_context)

def _resolve( # noqa: PLR0915 C901
Expand Down Expand Up @@ -387,7 +391,7 @@ def _convert_context(
if evaluation_context:
try:
s["targetingKey"] = evaluation_context.targeting_key
s.update(evaluation_context.attributes)
s.update(evaluation_context.attributes) # type: ignore[arg-type]
except ValueError as exc:
message = (
"could not serialize evaluation context to google.protobuf.Struct"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from openfeature.evaluation_context import EvaluationContext
from openfeature.event import ProviderEventDetails
from openfeature.exception import ErrorCode, FlagNotFoundError, GeneralError, ParseError
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
from openfeature.flag_evaluation import FlagResolutionDetails, FlagValueType, Reason

from ..config import Config
from .process.connector import FlagStateConnector
Expand Down Expand Up @@ -105,9 +105,13 @@ def resolve_integer_details(
def resolve_object_details(
self,
key: str,
default_value: typing.Union[dict, list],
default_value: typing.Union[
typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]
],
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[typing.Union[dict, list]]:
) -> FlagResolutionDetails[
typing.Union[typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]]
]:
return self._resolve(key, default_value, evaluation_context)

def _resolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def targeting(
raise ParseError(f"Invalid 'targeting' value in flag: {targeting}")

json_logic_context = evaluation_context.attributes if evaluation_context else {}
json_logic_context["$flagd"] = {"flagKey": key, "timestamp": int(time.time())}
json_logic_context["targetingKey"] = (
json_logic_context["$flagd"] = {"flagKey": key, "timestamp": int(time.time())} # type: ignore[index]
json_logic_context["targetingKey"] = ( # type: ignore[index]
evaluation_context.targeting_key if evaluation_context else None
)
return jsonLogic(targeting, json_logic_context, OPERATORS)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing_extensions import Protocol

from openfeature.evaluation_context import EvaluationContext
from openfeature.flag_evaluation import FlagResolutionDetails
from openfeature.flag_evaluation import FlagResolutionDetails, FlagValueType


class AbstractResolver(Protocol):
Expand Down Expand Up @@ -42,6 +42,10 @@ def resolve_integer_details(
def resolve_object_details(
self,
key: str,
default_value: typing.Union[dict, list],
default_value: typing.Union[
typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]
],
evaluation_context: typing.Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[typing.Union[dict, list]]: ...
) -> FlagResolutionDetails[
typing.Union[typing.Sequence[FlagValueType], typing.Mapping[str, FlagValueType]]
]: ...
2 changes: 1 addition & 1 deletion providers/openfeature-provider-ofrep/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
]
keywords = []
dependencies = [
"openfeature-sdk>=0.7.0",
"openfeature-sdk>=0.8.2",
"requests>=2.27.0"
]
requires-python = ">=3.9"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from collections.abc import Mapping, Sequence
from datetime import datetime, timedelta, timezone
from email.utils import parsedate_to_datetime
from typing import Any, Callable, NoReturn, Optional, Union
Expand All @@ -18,7 +19,12 @@
TargetingKeyMissingError,
TypeMismatchError,
)
from openfeature.flag_evaluation import FlagResolutionDetails, FlagType, Reason
from openfeature.flag_evaluation import (
FlagResolutionDetails,
FlagType,
FlagValueType,
Reason,
)
from openfeature.hook import Hook
from openfeature.provider import AbstractProvider, Metadata

Expand Down Expand Up @@ -100,9 +106,11 @@ def resolve_float_details(
def resolve_object_details(
self,
flag_key: str,
default_value: Union[dict, list],
default_value: Union[Sequence[FlagValueType], Mapping[str, FlagValueType]],
evaluation_context: Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[Union[dict, list]]:
) -> FlagResolutionDetails[
Union[Sequence[FlagValueType], Mapping[str, FlagValueType]]
]:
return self._resolve(
FlagType.OBJECT, flag_key, default_value, evaluation_context
)
Expand All @@ -117,7 +125,16 @@ def _resolve(
self,
flag_type: FlagType,
flag_key: str,
default_value: Union[bool, str, int, float, dict, list],
default_value: Union[
bool,
str,
int,
float,
dict,
list,
Sequence[FlagValueType],
Mapping[str, FlagValueType],
],
evaluation_context: Optional[EvaluationContext] = None,
) -> FlagResolutionDetails[Any]:
now = datetime.now(timezone.utc)
Expand Down