Skip to content

Commit 6451cec

Browse files
committed
chore: fix typing
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
1 parent 63c5a5b commit 6451cec

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

openfeature/provider/in_memory_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass, field
66

77
from openfeature._backports.strenum import StrEnum
8-
from openfeature.evaluation_context import EvaluationContext
8+
from openfeature.evaluation_context import EvaluationContext, EvaluationContextAttribute
99
from openfeature.exception import ErrorCode
1010
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
1111
from openfeature.provider import AbstractProvider, Metadata
@@ -26,7 +26,7 @@ class InMemoryMetadata(Metadata):
2626
class InMemoryTrackingEvent():
2727
value: float | None = None
2828
details: dict[str, typing.Any] = field(default_factory=dict)
29-
eval_context_attributes: dict[str, typing.Any] = field(default_factory=dict)
29+
eval_context_attributes: Mapping[str, EvaluationContextAttribute] = field(default_factory=dict)
3030

3131

3232

@@ -195,7 +195,7 @@ async def _resolve_async(
195195
def track(self, tracking_event_name: str, evaluation_context: EvaluationContext | None = None, tracking_event_details: TrackingEventDetails | None = None) -> None:
196196
value = tracking_event_details.value if tracking_event_details is not None else None
197197
details = tracking_event_details.attributes if tracking_event_details is not None else {}
198-
eval_context_attributes = evaluation_context.attributes if evaluation_context is not None else None
198+
eval_context_attributes = evaluation_context.attributes if evaluation_context is not None else {}
199199

200200
self._tracking_events[tracking_event_name] = InMemoryTrackingEvent(
201201
value=value,

openfeature/track/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
from collections.abc import Mapping, Sequence
44
import typing
55

6-
TrackingAttribute = typing.TypeAlias = bool | int | float | str | Sequence["TrackingAttribute"] | Mapping[str, "TrackingAttribute"]
6+
TrackingValue: typing.TypeAlias = bool | int | float | str | Sequence["TrackingValue"] | Mapping[str, "TrackingValue"]
77

88
class TrackingEventDetails:
99
value: float | None
10-
attributes: TrackingAttribute
10+
attributes: dict[str, TrackingValue]
1111

12-
def __init__(self, value: float | None = None, attributes: TrackingAttribute | None = None):
12+
def __init__(self, value: float | None = None, attributes: dict[str, TrackingValue] | None = None):
1313
self.value = value
1414
self.attributes = attributes or {}
1515

16-
def add(self, key: str, value: TrackingAttribute) -> "TrackingEventDetails":
16+
def add(self, key: str, value: TrackingValue) -> "TrackingEventDetails":
1717
self.attributes[key] = value
1818
return self

0 commit comments

Comments
 (0)