-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtypes.py
More file actions
54 lines (38 loc) · 1.39 KB
/
types.py
File metadata and controls
54 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import typing
from datetime import datetime
from flag_engine.context.types import EvaluationContext
from flag_engine.engine import ContextValue
from flag_engine.result.types import EvaluationResult, FlagResult
from typing_extensions import NotRequired, TypeAlias
_JsonScalarType: TypeAlias = typing.Union[
int,
str,
float,
bool,
None,
]
JsonType: TypeAlias = typing.Union[
_JsonScalarType,
typing.Dict[str, "JsonType"],
typing.List["JsonType"],
]
class StreamEvent(typing.TypedDict):
updated_at: datetime
class TraitConfig(typing.TypedDict):
value: ContextValue
transient: bool
TraitMapping: TypeAlias = typing.Mapping[str, typing.Union[ContextValue, TraitConfig]]
class ApplicationMetadata(typing.TypedDict):
name: NotRequired[str]
version: NotRequired[str]
class SegmentMetadata(typing.TypedDict):
flagsmith_id: NotRequired[int]
"""The ID of the segment used in Flagsmith API."""
source: NotRequired[typing.Literal["api", "identity_overrides"]]
"""The source of the segment, e.g. 'api', 'identity_overrides'."""
class FeatureMetadata(typing.TypedDict):
flagsmith_id: NotRequired[int]
"""The ID of the feature used in Flagsmith API."""
SDKEvaluationContext = EvaluationContext[SegmentMetadata, FeatureMetadata]
SDKEvaluationResult = EvaluationResult[SegmentMetadata, FeatureMetadata]
SDKFlagResult = FlagResult[FeatureMetadata]