flagsmith 3.6.0__tar.gz → 3.7.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.
- {flagsmith-3.6.0 → flagsmith-3.7.0}/PKG-INFO +3 -4
- flagsmith-3.6.0/Readme.md → flagsmith-3.7.0/README.md +2 -2
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/exceptions.py +4 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/flagsmith.py +10 -11
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/models.py +4 -2
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/utils/identities.py +5 -3
- {flagsmith-3.6.0 → flagsmith-3.7.0}/pyproject.toml +3 -5
- {flagsmith-3.6.0 → flagsmith-3.7.0}/LICENSE +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/__init__.py +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/analytics.py +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/offline_handlers.py +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/polling_manager.py +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/py.typed +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/streaming_manager.py +0 -0
- {flagsmith-3.6.0 → flagsmith-3.7.0}/flagsmith/utils/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flagsmith
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.0
|
|
4
4
|
Summary: Flagsmith Python SDK
|
|
5
5
|
License: BSD3
|
|
6
6
|
Keywords: feature,flag,flagsmith,remote,config
|
|
@@ -14,7 +14,6 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Requires-Dist: flagsmith-flag-engine (>=5.1.0,<6.0.0)
|
|
17
|
-
Requires-Dist: pytz (>=2023.4,<2024.0)
|
|
18
17
|
Requires-Dist: requests (>=2.27.1,<3.0.0)
|
|
19
18
|
Requires-Dist: requests-futures (>=1.0.0,<2.0.0)
|
|
20
19
|
Requires-Dist: sseclient-py (>=1.8.0,<2.0.0)
|
|
@@ -33,11 +32,11 @@ The SDK for Python applications for [https://www.flagsmith.com/](https://www.fla
|
|
|
33
32
|
## Adding to your project
|
|
34
33
|
|
|
35
34
|
For full documentation visit
|
|
36
|
-
[https://docs.flagsmith.com/clients/server-side](https://docs.flagsmith.com/clients/server-side).
|
|
35
|
+
[https://docs.flagsmith.com/clients/server-side?language=python](https://docs.flagsmith.com/clients/server-side?language=python).
|
|
37
36
|
|
|
38
37
|
## Contributing
|
|
39
38
|
|
|
40
|
-
Please read [CONTRIBUTING.md](
|
|
39
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code
|
|
41
40
|
of conduct, and the process for submitting pull requests
|
|
42
41
|
|
|
43
42
|
## Getting Help
|
|
@@ -10,11 +10,11 @@ The SDK for Python applications for [https://www.flagsmith.com/](https://www.fla
|
|
|
10
10
|
## Adding to your project
|
|
11
11
|
|
|
12
12
|
For full documentation visit
|
|
13
|
-
[https://docs.flagsmith.com/clients/server-side](https://docs.flagsmith.com/clients/server-side).
|
|
13
|
+
[https://docs.flagsmith.com/clients/server-side?language=python](https://docs.flagsmith.com/clients/server-side?language=python).
|
|
14
14
|
|
|
15
15
|
## Contributing
|
|
16
16
|
|
|
17
|
-
Please read [CONTRIBUTING.md](
|
|
17
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code
|
|
18
18
|
of conduct, and the process for submitting pull requests
|
|
19
19
|
|
|
20
20
|
## Getting Help
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
3
|
import typing
|
|
4
|
-
from datetime import datetime
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
5
|
|
|
6
|
-
import pytz
|
|
7
6
|
import requests
|
|
8
7
|
from flag_engine import engine
|
|
9
8
|
from flag_engine.environments.models import EnvironmentModel
|
|
@@ -212,7 +211,7 @@ class Flagsmith:
|
|
|
212
211
|
) from e
|
|
213
212
|
|
|
214
213
|
if stream_updated_at.tzinfo is None:
|
|
215
|
-
stream_updated_at =
|
|
214
|
+
stream_updated_at = stream_updated_at.astimezone(timezone.utc)
|
|
216
215
|
|
|
217
216
|
if not self._environment:
|
|
218
217
|
raise ValueError(
|
|
@@ -220,7 +219,7 @@ class Flagsmith:
|
|
|
220
219
|
)
|
|
221
220
|
environment_updated_at = self._environment.updated_at
|
|
222
221
|
if environment_updated_at.tzinfo is None:
|
|
223
|
-
environment_updated_at =
|
|
222
|
+
environment_updated_at = environment_updated_at.astimezone(timezone.utc)
|
|
224
223
|
|
|
225
224
|
if stream_updated_at > environment_updated_at:
|
|
226
225
|
self.update_environment()
|
|
@@ -324,9 +323,9 @@ class Flagsmith:
|
|
|
324
323
|
|
|
325
324
|
def _get_environment_flags_from_api(self) -> Flags:
|
|
326
325
|
try:
|
|
327
|
-
json_response: typing.List[
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
json_response: typing.List[typing.Mapping[str, JsonType]] = (
|
|
327
|
+
self._get_json_response(url=self.environment_flags_url, method="GET")
|
|
328
|
+
)
|
|
330
329
|
return Flags.from_api_flags(
|
|
331
330
|
api_flags=json_response,
|
|
332
331
|
analytics_processor=self._analytics_processor,
|
|
@@ -344,10 +343,10 @@ class Flagsmith:
|
|
|
344
343
|
) -> Flags:
|
|
345
344
|
try:
|
|
346
345
|
data = generate_identities_data(identifier, traits)
|
|
347
|
-
json_response: typing.Dict[
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
346
|
+
json_response: typing.Dict[str, typing.List[typing.Dict[str, JsonType]]] = (
|
|
347
|
+
self._get_json_response(
|
|
348
|
+
url=self.identities_url, method="POST", body=data
|
|
349
|
+
)
|
|
351
350
|
)
|
|
352
351
|
return Flags.from_api_flags(
|
|
353
352
|
api_flags=json_response["flags"],
|
|
@@ -6,7 +6,7 @@ from dataclasses import dataclass, field
|
|
|
6
6
|
from flag_engine.features.models import FeatureStateModel
|
|
7
7
|
|
|
8
8
|
from flagsmith.analytics import AnalyticsProcessor
|
|
9
|
-
from flagsmith.exceptions import
|
|
9
|
+
from flagsmith.exceptions import FlagsmithFeatureDoesNotExistError
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
@@ -135,7 +135,9 @@ class Flags:
|
|
|
135
135
|
except KeyError:
|
|
136
136
|
if self.default_flag_handler:
|
|
137
137
|
return self.default_flag_handler(feature_name)
|
|
138
|
-
raise
|
|
138
|
+
raise FlagsmithFeatureDoesNotExistError(
|
|
139
|
+
"Feature does not exist: %s" % feature_name
|
|
140
|
+
)
|
|
139
141
|
|
|
140
142
|
if self._analytics_processor and hasattr(flag, "feature_name"):
|
|
141
143
|
self._analytics_processor.track_feature(flag.feature_name)
|
|
@@ -13,7 +13,9 @@ def generate_identities_data(
|
|
|
13
13
|
) -> Identity:
|
|
14
14
|
return {
|
|
15
15
|
"identifier": identifier,
|
|
16
|
-
"traits":
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
"traits": (
|
|
17
|
+
[{"trait_key": k, "trait_value": v} for k, v in traits.items()]
|
|
18
|
+
if traits
|
|
19
|
+
else []
|
|
20
|
+
),
|
|
19
21
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "flagsmith"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.7.0"
|
|
4
4
|
description = "Flagsmith Python SDK"
|
|
5
5
|
authors = ["Flagsmith <support@flagsmith.com>"]
|
|
6
6
|
license = "BSD3"
|
|
7
|
-
readme = "
|
|
7
|
+
readme = "README.md"
|
|
8
8
|
keywords = ["feature", "flag", "flagsmith", "remote", "config"]
|
|
9
9
|
documentation = "https://docs.flagsmith.com"
|
|
10
10
|
packages = [{ include = "flagsmith" }]
|
|
@@ -15,7 +15,6 @@ requests = "^2.27.1"
|
|
|
15
15
|
requests-futures = "^1.0.0"
|
|
16
16
|
flagsmith-flag-engine = "^5.1.0"
|
|
17
17
|
sseclient-py = "^1.8.0"
|
|
18
|
-
pytz = "^2023.4"
|
|
19
18
|
|
|
20
19
|
[tool.poetry.group.dev]
|
|
21
20
|
optional = true
|
|
@@ -23,7 +22,7 @@ optional = true
|
|
|
23
22
|
[tool.poetry.group.dev.dependencies]
|
|
24
23
|
pytest = "^7.4.0"
|
|
25
24
|
pytest-mock = "^3.6.1"
|
|
26
|
-
black = "
|
|
25
|
+
black = ">=23.3,<25.0"
|
|
27
26
|
pre-commit = "^2.17.0"
|
|
28
27
|
responses = "^0.24.1"
|
|
29
28
|
flake8 = "^6.1.0"
|
|
@@ -31,7 +30,6 @@ isort = "^5.12.0"
|
|
|
31
30
|
mypy = "^1.7.1"
|
|
32
31
|
types-requests = "^2.31.0.10"
|
|
33
32
|
pytest-cov = "^4.1.0"
|
|
34
|
-
types-pytz = "^2024.1.0.20240203"
|
|
35
33
|
|
|
36
34
|
[tool.mypy]
|
|
37
35
|
plugins = ["pydantic.mypy"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|