Skip to content

Commit 685d369

Browse files
Merge branch 'main' into feat/analytics-url-213
2 parents 2c5dbc5 + 51d6693 commit 685d369

11 files changed

Lines changed: 859 additions & 520 deletions

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
max-parallel: 5
1515
matrix:
16-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
16+
python-version: ['3.10', '3.11', '3.12', '3.13']
1717

1818
steps:
1919
- name: Cloning repo

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: isort
66
- repo: https://github.com/psf/black-pre-commit-mirror
7-
rev: 26.5.0
7+
rev: 26.5.1
88
hooks:
99
- id: black
1010
- repo: https://github.com/pycqa/flake8

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "5.5.0"
2+
".": "6.0.0"
33
}

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Changelog
22

3+
## [6.0.0](https://github.com/Flagsmith/flagsmith-python-client/compare/v5.5.0...v6.0.0) (2026-06-26)
4+
5+
### ⚠ BREAKING CHANGES
6+
7+
- drop Python 3.9 support to allow urllib3 >=2.7.0
8+
([#227](https://github.com/Flagsmith/flagsmith-python-client/issues/227))
9+
10+
### Features
11+
12+
- only track exposure when experiment feature is enabled
13+
([#226](https://github.com/Flagsmith/flagsmith-python-client/issues/226))
14+
([30112aa](https://github.com/Flagsmith/flagsmith-python-client/commit/30112aa187af66c00171000b199e158c88142b7c))
15+
16+
### Bug Fixes
17+
18+
- Background threads leaking across tests ([#229](https://github.com/Flagsmith/flagsmith-python-client/issues/229))
19+
([0615a9d](https://github.com/Flagsmith/flagsmith-python-client/commit/0615a9d760b047ae8a02dec8ac412f171e9e7f5e))
20+
21+
### CI
22+
23+
- pre-commit autoupdate ([#219](https://github.com/Flagsmith/flagsmith-python-client/issues/219))
24+
([134e6b6](https://github.com/Flagsmith/flagsmith-python-client/commit/134e6b65ebe11e89a37ae2d1c98b487871d5a216))
25+
26+
### Dependency Updates
27+
28+
- drop Python 3.9 support to allow urllib3 >=2.7.0
29+
([#227](https://github.com/Flagsmith/flagsmith-python-client/issues/227))
30+
([814e67e](https://github.com/Flagsmith/flagsmith-python-client/commit/814e67ef1e1e5905dfcfdfd3e629cdf3fc7855e6))
31+
32+
### Other
33+
34+
- **deps-dev:** bump pytest from 7.4.4 to 9.0.3
35+
([#228](https://github.com/Flagsmith/flagsmith-python-client/issues/228))
36+
([f00eff9](https://github.com/Flagsmith/flagsmith-python-client/commit/f00eff954527e5d031789be7a33466c05f9d1adb))
37+
- **deps:** bump idna from 3.10 to 3.15 ([#218](https://github.com/Flagsmith/flagsmith-python-client/issues/218))
38+
([4d71722](https://github.com/Flagsmith/flagsmith-python-client/commit/4d71722421d3692af07d68bbf71216b4de1b2eed))
39+
340
## [5.5.0](https://github.com/Flagsmith/flagsmith-python-client/compare/v5.4.0...v5.5.0) (2026-06-09)
441

542
### Features

flagsmith/flagsmith.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,13 @@ def get_experiment_flag(
370370
371371
Skips the exposure event when the resolved flag is a `DefaultFlag`
372372
(i.e. the feature was not present and was served via the
373-
`default_flag_handler`), to keep experimentation data clean.
373+
`default_flag_handler`) or when the feature is disabled, to keep
374+
experimentation data clean.
374375
"""
375376
if not self._event_processor:
376377
raise ValueError("Events must be enabled to use experiment flags.")
377378
flag = self.get_identity_flags(identifier, traits).get_flag(feature_name)
378-
if isinstance(flag, Flag):
379+
if isinstance(flag, Flag) and flag.enabled:
379380
self.track_exposure_event(
380381
feature_name=feature_name,
381382
identifier=identifier,

flagsmith/polling_manager.py

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

33
import logging
44
import threading
5-
import time
65
import typing
76

87
if typing.TYPE_CHECKING:
@@ -26,8 +25,11 @@ def __init__(
2625

2726
def run(self) -> None:
2827
while not self._stop_event.is_set():
29-
self.main.update_environment()
30-
time.sleep(self.refresh_interval_seconds)
28+
try:
29+
self.main.update_environment()
30+
except Exception:
31+
logger.exception("Error updating environment")
32+
self._stop_event.wait(self.refresh_interval_seconds)
3133

3234
def stop(self) -> None:
3335
self._stop_event.set()

flagsmith/streaming_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ def run(self) -> None:
4040
for event in sse_client.events():
4141
self.on_event(map_sse_event_to_stream_event(event))
4242

43-
except (requests.RequestException, ValueError, TypeError):
43+
except Exception:
4444
logger.exception("Error opening or reading from the event stream")
45+
self._stop_event.wait(1)
4546

4647
def stop(self) -> None:
4748
self._stop_event.set()

poetry.lock

Lines changed: 758 additions & 500 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "flagsmith"
3-
version = "5.5.0"
3+
version = "6.0.0"
44
description = "Flagsmith Python SDK"
55
authors = ["Flagsmith <support@flagsmith.com>"]
66
license = "BSD3"
@@ -12,7 +12,7 @@ packages = [{ include = "flagsmith" }]
1212
[tool.poetry.dependencies]
1313
flagsmith-flag-engine = "^10.2.0"
1414
iso8601 = { version = "^2.1.0", python = "<3.11" }
15-
python = ">=3.9,<4"
15+
python = ">=3.10,<4"
1616
requests = "^2.32.3"
1717
requests-futures = "^1.0.1"
1818
sseclient-py = "^1.8.0"
@@ -22,11 +22,11 @@ typing-extensions = "^4.15.0"
2222
optional = true
2323

2424
[tool.poetry.group.dev.dependencies]
25-
mypy = { version = "^1.16.1", python = ">=3.9,<4" }
26-
pytest = "^7.4.0"
25+
mypy = "^1.16.1"
26+
pytest = ">=7.4,<10.0"
2727
pytest-cov = "^4.1.0"
2828
pytest-mock = "^3.6.1"
29-
pre-commit = { version = "^4.2.0", python = ">=3.9,<4" }
29+
pre-commit = "^4.2.0"
3030
responses = "^0.24.1"
3131
types-requests = "^2.32"
3232
pyfakefs = "^5.9.2"
@@ -35,7 +35,7 @@ pyfakefs = "^5.9.2"
3535
exclude = ["example/*"]
3636

3737
[tool.black]
38-
target-version = ["py39"]
38+
target-version = ["py310"]
3939

4040
[build-system]
4141
requires = ["poetry-core>=1.0.0"]

tests/conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ def tracking_init(self: Flagsmith, *args: typing.Any, **kwargs: typing.Any) -> N
4141
monkeypatch.setattr(Flagsmith, "__init__", tracking_init)
4242
yield
4343
for flagsmith in instances:
44-
if getattr(flagsmith, "environment_data_polling_manager_thread", None):
45-
flagsmith.environment_data_polling_manager_thread.stop()
46-
if getattr(flagsmith, "event_stream_thread", None):
47-
flagsmith.event_stream_thread.stop()
44+
if polling := getattr(
45+
flagsmith, "environment_data_polling_manager_thread", None
46+
):
47+
polling.stop()
48+
polling.join(timeout=5)
49+
if stream := getattr(flagsmith, "event_stream_thread", None):
50+
stream.stop()
51+
stream.join(timeout=5)
4852
if flagsmith._event_processor:
4953
flagsmith._event_processor.stop()
5054

0 commit comments

Comments
 (0)