flagsmith-flag-engine 10.1.0__tar.gz → 11.0.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.
Files changed (29) hide show
  1. {flagsmith_flag_engine-10.1.0/flagsmith_flag_engine.egg-info → flagsmith_flag_engine-11.0.0}/PKG-INFO +4 -2
  2. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/context/types.py +1 -0
  3. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/result/types.py +2 -1
  4. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/segments/evaluator.py +17 -16
  5. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0/flagsmith_flag_engine.egg-info}/PKG-INFO +4 -2
  6. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/setup.py +3 -2
  7. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/LICENSE.txt +0 -0
  8. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/README.md +0 -0
  9. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/__init__.py +0 -0
  10. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/context/__init__.py +0 -0
  11. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/context/mappers.py +0 -0
  12. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/engine.py +0 -0
  13. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/py.typed +0 -0
  14. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/result/__init__.py +0 -0
  15. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/segments/__init__.py +0 -0
  16. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/segments/constants.py +0 -0
  17. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/segments/types.py +0 -0
  18. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/segments/utils.py +0 -0
  19. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/utils/__init__.py +0 -0
  20. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/utils/hashing.py +0 -0
  21. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/utils/json/__init__.py +0 -0
  22. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/utils/json/encoders.py +0 -0
  23. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/utils/semver.py +0 -0
  24. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flag_engine/utils/types.py +0 -0
  25. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flagsmith_flag_engine.egg-info/SOURCES.txt +0 -0
  26. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flagsmith_flag_engine.egg-info/dependency_links.txt +0 -0
  27. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flagsmith_flag_engine.egg-info/requires.txt +0 -0
  28. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/flagsmith_flag_engine.egg-info/top_level.txt +0 -0
  29. {flagsmith_flag_engine-10.1.0 → flagsmith_flag_engine-11.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flagsmith-flag-engine
3
- Version: 10.1.0
3
+ Version: 11.0.0
4
4
  Summary: Flag engine for the Flagsmith API.
5
5
  Home-page: https://github.com/Flagsmith/flagsmith-engine
6
6
  Author: Flagsmith
@@ -8,11 +8,12 @@ Author-email: support@flagsmith.com
8
8
  License: BSD3
9
9
  Classifier: License :: OSI Approved :: BSD License
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
11
  Classifier: Programming Language :: Python :: 3.10
13
12
  Classifier: Programming Language :: Python :: 3.11
14
13
  Classifier: Programming Language :: Python :: 3.12
15
14
  Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Python: >=3.10
16
17
  Description-Content-Type: text/markdown
17
18
  License-File: LICENSE.txt
18
19
  Requires-Dist: jsonpath-rfc9535<1,>=0.1.5
@@ -27,6 +28,7 @@ Dynamic: home-page
27
28
  Dynamic: license
28
29
  Dynamic: license-file
29
30
  Dynamic: requires-dist
31
+ Dynamic: requires-python
30
32
  Dynamic: summary
31
33
 
32
34
  [![Feature Flag, Remote Config and A/B Testing platform, Flagsmith](https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png)](https://www.flagsmith.com/)
@@ -23,6 +23,7 @@ class EnvironmentContext(TypedDict):
23
23
 
24
24
 
25
25
  class FeatureValue(TypedDict):
26
+ key: NotRequired[str]
26
27
  value: Any
27
28
  weight: float
28
29
  priority: int
@@ -4,7 +4,7 @@
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
- from typing import Any, Dict, Generic, List
7
+ from typing import Any, Dict, Generic, List, Optional
8
8
 
9
9
  from typing_extensions import NotRequired, TypedDict
10
10
 
@@ -16,6 +16,7 @@ class FlagResult(TypedDict, Generic[FeatureMetadataT]):
16
16
  enabled: bool
17
17
  value: Any
18
18
  reason: str
19
+ variant: Optional[str]
19
20
  metadata: NotRequired[FeatureMetadataT]
20
21
 
21
22
 
@@ -178,38 +178,39 @@ def get_flag_result_from_context(
178
178
  """
179
179
  key = _get_identity_key(context)
180
180
 
181
- flag_result: typing.Optional[FlagResult[FeatureMetadataT]] = None
181
+ value = feature_context["value"]
182
+ variant: typing.Optional[str] = None
182
183
 
183
184
  if key is not None and (variants := feature_context.get("variants")):
185
+ # Default to the control bucket; a matched named variant overrides this.
186
+ variant = "control"
187
+
184
188
  percentage_value = get_hashed_percentage_for_object_ids(
185
189
  [feature_context["key"], key]
186
190
  )
187
191
 
188
192
  start_percentage = 0.0
189
193
 
190
- for variant in sorted(
194
+ for feature_value in sorted(
191
195
  variants,
192
196
  key=operator.itemgetter("priority"),
193
197
  ):
194
- limit = (weight := variant["weight"]) + start_percentage
198
+ limit = (weight := feature_value["weight"]) + start_percentage
195
199
  if start_percentage <= percentage_value < limit:
196
- flag_result = {
197
- "enabled": feature_context["enabled"],
198
- "name": feature_context["name"],
199
- "reason": f"SPLIT; weight={weight}",
200
- "value": variant["value"],
201
- }
200
+ reason = f"SPLIT; weight={weight}"
201
+ value = feature_value["value"]
202
+ variant = feature_value.get("key")
202
203
  break
203
204
 
204
205
  start_percentage = limit
205
206
 
206
- if flag_result is None:
207
- flag_result = {
208
- "enabled": feature_context["enabled"],
209
- "name": feature_context["name"],
210
- "reason": reason,
211
- "value": feature_context["value"],
212
- }
207
+ flag_result: FlagResult[FeatureMetadataT] = {
208
+ "enabled": feature_context["enabled"],
209
+ "name": feature_context["name"],
210
+ "reason": reason,
211
+ "value": value,
212
+ "variant": variant,
213
+ }
213
214
 
214
215
  if metadata := feature_context.get("metadata"):
215
216
  flag_result["metadata"] = metadata
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flagsmith-flag-engine
3
- Version: 10.1.0
3
+ Version: 11.0.0
4
4
  Summary: Flag engine for the Flagsmith API.
5
5
  Home-page: https://github.com/Flagsmith/flagsmith-engine
6
6
  Author: Flagsmith
@@ -8,11 +8,12 @@ Author-email: support@flagsmith.com
8
8
  License: BSD3
9
9
  Classifier: License :: OSI Approved :: BSD License
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
11
  Classifier: Programming Language :: Python :: 3.10
13
12
  Classifier: Programming Language :: Python :: 3.11
14
13
  Classifier: Programming Language :: Python :: 3.12
15
14
  Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Python: >=3.10
16
17
  Description-Content-Type: text/markdown
17
18
  License-File: LICENSE.txt
18
19
  Requires-Dist: jsonpath-rfc9535<1,>=0.1.5
@@ -27,6 +28,7 @@ Dynamic: home-page
27
28
  Dynamic: license
28
29
  Dynamic: license-file
29
30
  Dynamic: requires-dist
31
+ Dynamic: requires-python
30
32
  Dynamic: summary
31
33
 
32
34
  [![Feature Flag, Remote Config and A/B Testing platform, Flagsmith](https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png)](https://www.flagsmith.com/)
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name="flagsmith-flag-engine",
5
- version="10.1.0",
5
+ version="11.0.0",
6
6
  author="Flagsmith",
7
7
  author_email="support@flagsmith.com",
8
8
  packages=find_packages(include=["flag_engine", "flag_engine.*"]),
@@ -12,6 +12,7 @@ setup(
12
12
  description="Flag engine for the Flagsmith API.",
13
13
  long_description=open("README.md").read(),
14
14
  long_description_content_type="text/markdown",
15
+ python_requires=">=3.10",
15
16
  install_requires=[
16
17
  "jsonpath-rfc9535>=0.1.5,<1",
17
18
  "semver>=3.0.4,<4",
@@ -20,10 +21,10 @@ setup(
20
21
  classifiers=[
21
22
  "License :: OSI Approved :: BSD License",
22
23
  "Programming Language :: Python :: 3",
23
- "Programming Language :: Python :: 3.9",
24
24
  "Programming Language :: Python :: 3.10",
25
25
  "Programming Language :: Python :: 3.11",
26
26
  "Programming Language :: Python :: 3.12",
27
27
  "Programming Language :: Python :: 3.13",
28
+ "Programming Language :: Python :: 3.14",
28
29
  ],
29
30
  )