Skip to content

Commit d95f1e8

Browse files
[AI-FSSDK] [FSSDK-12337] Type-restrict Experiment.type to ExperimentType
- Add ExperimentType Literal type in helpers/types.py: 'a/b', 'mab', 'cmab', 'feature_rollout' - Change Experiment.type from Optional[str] to Optional[ExperimentType]
1 parent 397bacd commit d95f1e8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

optimizely/entities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
if TYPE_CHECKING:
2424
# prevent circular dependenacy by skipping import at runtime
25-
from .helpers.types import ExperimentDict, TrafficAllocation, VariableDict, VariationDict, CmabDict
25+
from .helpers.types import ExperimentDict, ExperimentType, TrafficAllocation, VariableDict, VariationDict, CmabDict
2626

2727

2828
class BaseEntity:
@@ -87,7 +87,7 @@ def __init__(
8787
groupId: Optional[str] = None,
8888
groupPolicy: Optional[str] = None,
8989
cmab: Optional[CmabDict] = None,
90-
type: Optional[str] = None,
90+
type: Optional[ExperimentType] = None,
9191
**kwargs: Any
9292
):
9393
self.id = id

optimizely/helpers/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ class CmabDict(BaseEntity):
117117
trafficAllocation: int
118118

119119

120+
ExperimentType = Literal['a/b', 'mab', 'cmab', 'feature_rollout']
121+
120122
HoldoutStatus = Literal['Draft', 'Running', 'Concluded', 'Archived']
121123

122124

0 commit comments

Comments
 (0)