flagsmith 5.4.0__tar.gz → 5.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flagsmith
3
- Version: 5.4.0
3
+ Version: 5.5.0
4
4
  Summary: Flagsmith Python SDK
5
5
  License: BSD3
6
6
  License-File: LICENSE
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Programming Language :: Python :: 3.14
19
- Requires-Dist: flagsmith-flag-engine (>=10.0.4,<11.0.0)
19
+ Requires-Dist: flagsmith-flag-engine (>=10.2.0,<11.0.0)
20
20
  Requires-Dist: iso8601 (>=2.1.0,<3.0.0) ; python_version < "3.11"
21
21
  Requires-Dist: requests (>=2.32.3,<3.0.0)
22
22
  Requires-Dist: requests-futures (>=1.0.1,<2.0.0)
@@ -39,6 +39,7 @@ class FeatureSegmentModel(typing.TypedDict):
39
39
 
40
40
  class MultivariateFeatureOptionModel(typing.TypedDict):
41
41
  value: str
42
+ key: NotRequired[typing.Optional[str]]
42
43
 
43
44
 
44
45
  class MultivariateFeatureStateValueModel(typing.TypedDict):
@@ -362,11 +362,11 @@ class Flagsmith:
362
362
  if not self._event_processor:
363
363
  raise ValueError("Events must be enabled to use experiment flags.")
364
364
  flag = self.get_identity_flags(identifier, traits).get_flag(feature_name)
365
- if not flag.is_default:
365
+ if isinstance(flag, Flag):
366
366
  self.track_exposure_event(
367
367
  feature_name=feature_name,
368
368
  identifier=identifier,
369
- value=flag.value,
369
+ value=flag.variant if flag.variant is not None else flag.value,
370
370
  traits=traits,
371
371
  )
372
372
  return flag
@@ -7,6 +7,7 @@ from datetime import datetime, timezone
7
7
  import sseclient
8
8
  from flag_engine.context.types import (
9
9
  FeatureContext,
10
+ FeatureValue,
10
11
  SegmentContext,
11
12
  SegmentRule,
12
13
  StrValueSegmentCondition,
@@ -245,11 +246,13 @@ def _map_environment_document_feature_states_to_feature_contexts(
245
246
  if multivariate_feature_state_values := feature_state.get(
246
247
  "multivariate_feature_state_values"
247
248
  ):
248
- feature_context["variants"] = [
249
- {
250
- "value": multivariate_feature_state_value[
251
- "multivariate_feature_option"
252
- ]["value"],
249
+ variants: list[FeatureValue] = []
250
+ for multivariate_feature_state_value in multivariate_feature_state_values:
251
+ multivariate_feature_option = multivariate_feature_state_value[
252
+ "multivariate_feature_option"
253
+ ]
254
+ variant: FeatureValue = {
255
+ "value": multivariate_feature_option["value"],
253
256
  "weight": multivariate_feature_state_value["percentage_allocation"],
254
257
  "priority": (
255
258
  multivariate_feature_state_value.get("id")
@@ -258,8 +261,10 @@ def _map_environment_document_feature_states_to_feature_contexts(
258
261
  ).int
259
262
  ),
260
263
  }
261
- for multivariate_feature_state_value in multivariate_feature_state_values
262
- ]
264
+ if (key := multivariate_feature_option.get("key")) is not None:
265
+ variant["key"] = key
266
+ variants.append(variant)
267
+ feature_context["variants"] = variants
263
268
 
264
269
  if feature_segment := feature_state.get("feature_segment"):
265
270
  feature_context["priority"] = feature_segment["priority"]
@@ -51,6 +51,7 @@ class DefaultFlag(BaseFlag):
51
51
  class Flag(BaseFlag):
52
52
  feature_id: int
53
53
  feature_name: str
54
+ variant: typing.Optional[str] = None
54
55
  is_default: bool = field(default=False)
55
56
 
56
57
  @classmethod
@@ -64,6 +65,7 @@ class Flag(BaseFlag):
64
65
  value=flag_result["value"],
65
66
  feature_name=flag_result["name"],
66
67
  feature_id=metadata["id"],
68
+ variant=flag_result.get("variant"),
67
69
  )
68
70
  raise ValueError(
69
71
  "FlagResult metadata is missing. Cannot create Flag instance. "
@@ -77,6 +79,7 @@ class Flag(BaseFlag):
77
79
  value=flag_data["feature_state_value"],
78
80
  feature_name=flag_data["feature"]["name"],
79
81
  feature_id=flag_data["feature"]["id"],
82
+ variant=flag_data.get("variant"),
80
83
  )
81
84
 
82
85
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "flagsmith"
3
- version = "5.4.0"
3
+ version = "5.5.0"
4
4
  description = "Flagsmith Python SDK"
5
5
  authors = ["Flagsmith <support@flagsmith.com>"]
6
6
  license = "BSD3"
@@ -10,7 +10,7 @@ documentation = "https://docs.flagsmith.com"
10
10
  packages = [{ include = "flagsmith" }]
11
11
 
12
12
  [tool.poetry.dependencies]
13
- flagsmith-flag-engine = "^10.0.4"
13
+ flagsmith-flag-engine = "^10.2.0"
14
14
  iso8601 = { version = "^2.1.0", python = "<3.11" }
15
15
  python = ">=3.9,<4"
16
16
  requests = "^2.32.3"
File without changes
File without changes
File without changes
File without changes