-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
237 lines (189 loc) · 5.83 KB
/
Copy pathtypes.py
File metadata and controls
237 lines (189 loc) · 5.83 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
from __future__ import annotations
import sys
from typing import Any, Callable, Literal, TypedDict
if sys.version_info >= (3, 11):
from typing import NotRequired
else:
from typing_extensions import NotRequired
AttributeValue = Any
VariableValue = Any
VariationValue = Any
Context = dict[str, AttributeValue]
FeatureKey = str
VariableKey = str
SegmentKey = str
RuleKey = str
BucketKey = str
BucketValue = int
LogLevel = Literal["fatal", "error", "warn", "info", "debug"]
EventName = Literal[
"datafile_set", "context_set", "sticky_features_set",
"sticky_variables_set", "error"
]
class EvaluatedFeature(TypedDict, total=False):
enabled: bool
variation: VariationValue
variables: dict[VariableKey, VariableValue]
StickyFeatures = dict[FeatureKey, EvaluatedFeature]
StickyVariables = dict[VariableKey, VariableValue]
EvaluatedFeatures = dict[FeatureKey, EvaluatedFeature]
EvaluatedVariables = dict[VariableKey, VariableValue]
class RequiredFeature(TypedDict, total=False):
feature: FeatureKey
enabled: bool
variation: VariationValue
class VariableOverride(TypedDict, total=False):
key: str
keyPath: list[str]
conditions: Any
segments: Any
requiredFeatures: str | RequiredFeature | list[str | RequiredFeature]
value: VariableValue
class Variation(TypedDict, total=False):
value: VariationValue
weight: int
variables: dict[VariableKey, VariableValue]
variableOverrides: dict[VariableKey, list[VariableOverride]]
class RequiredFeatureRef(TypedDict, total=False):
key: FeatureKey
variation: VariationValue
class VariableSchema(TypedDict, total=False):
type: str
defaultValue: VariableValue
disabledValue: VariableValue
useDefaultWhenDisabled: bool
deprecated: bool
class GlobalVariable(VariableSchema, total=False):
key: VariableKey
hash: str
requiredFeatures: str | RequiredFeature | list[str | RequiredFeature]
overrides: list[VariableOverride]
class Allocation(TypedDict):
variation: VariationValue
range: list[int]
class Traffic(TypedDict, total=False):
key: RuleKey
segments: Any
percentage: int
enabled: bool
variation: VariationValue
variables: dict[VariableKey, VariableValue]
variationWeights: dict[str, int]
variableOverrides: dict[VariableKey, list[VariableOverride]]
allocation: list[Allocation]
class Force(TypedDict, total=False):
conditions: Any
segments: Any
enabled: bool
variation: VariationValue
variables: dict[VariableKey, VariableValue]
class Feature(TypedDict, total=False):
key: FeatureKey
hash: str
deprecated: bool
required: list[str | RequiredFeatureRef]
requiredFeatures: str | RequiredFeature | list[str | RequiredFeature]
variablesSchema: dict[VariableKey, VariableSchema]
disabledVariationValue: VariationValue
variations: list[Variation]
bucketBy: str | list[str] | dict[str, list[str]]
traffic: list[Traffic]
force: list[Force]
ranges: list[list[int]]
class Segment(TypedDict, total=False):
archived: bool
description: str
conditions: Any
class DatafileContent(TypedDict):
schemaVersion: str
revision: str
featurevisorVersion: NotRequired[str]
segments: dict[SegmentKey, Segment]
features: dict[FeatureKey, Feature]
variables: NotRequired[dict[VariableKey, GlobalVariable]]
class Evaluation(TypedDict, total=False):
type: Literal["flag", "variation", "variable"]
featureKey: FeatureKey
reason: str
bucketKey: BucketKey
bucketValue: BucketValue
ruleKey: RuleKey
error: Exception
enabled: bool
traffic: Traffic
forceIndex: int
force: Force
required: list[str | RequiredFeatureRef]
requiredFeatures: str | RequiredFeature | list[str | RequiredFeature]
sticky: EvaluatedFeature
variation: Variation
variationValue: VariationValue
variableKey: VariableKey
variableValue: VariableValue
variableSchema: VariableSchema
variable: GlobalVariable
variableOverrideIndex: int
variableOverrideKey: str
variableOverridePath: list[str]
class FeaturevisorDiagnostic(TypedDict, total=False):
level: LogLevel
code: str
message: str
module: str
moduleName: str
originalError: Exception
details: dict[str, Any]
class FeaturevisorModule(TypedDict, total=False):
name: str
before: Callable[[dict[str, Any]], dict[str, Any]]
bucketKey: Callable[[dict[str, Any]], BucketKey]
bucketValue: Callable[[dict[str, Any]], BucketValue]
after: Callable[[Evaluation, dict[str, Any]], Evaluation]
beforeEvaluation: Callable[[dict[str, Any]], dict[str, Any]]
afterEvaluation: Callable[[Evaluation, dict[str, Any]], Evaluation]
setup: Callable[[dict[str, Any]], None]
close: Callable[[], None]
class TestResultAssertionError(TypedDict, total=False):
type: str
expected: Any
actual: Any
message: str
details: dict[str, Any]
class TestResultAssertion(TypedDict, total=False):
description: str
duration: int
passed: bool
errors: list[TestResultAssertionError]
class TestResult(TypedDict, total=False):
type: str
key: str
notFound: bool
passed: bool
duration: int
assertions: list[TestResultAssertion]
class CLIOptions(TypedDict, total=False):
projectDirectoryPath: str
environment: str
feature: str
variable: str
context: str
keyPattern: str
assertionPattern: str
onlyFailures: bool
quiet: bool
verbose: bool
showDatafile: bool
variation: bool
n: int
inflate: int
with_scopes: bool
with_tags: bool
schema_version: str
populateUuid: list[str]
class ProjectConfig(TypedDict, total=False):
environments: list[str] | bool
datafilesDirectoryPath: str
datafileNamePattern: str
testsDirectoryPath: str
featuresDirectoryPath: str
segmentsDirectoryPath: str