Skip to content

Commit fbfed74

Browse files
[FSSDK-13301] Raise minimum Python to 3.10, add 3.13–3.15 (#530)
* [FSSDK-13301] Raise minimum Python to 3.10, add 3.13–3.15 - Remove the last version_info < (3, 10) guard; import TypeGuard from typing - setup.py: add python_requires='>=3.10'; classifiers 3.10–3.15 - README: add 5.9+ requirements row and EOL support policy - ruff target-version py39 -> py310 - CI: test on 3.10–3.15 and pypy-3.10/3.11/3.12; type-check on 3.10–3.15 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [FSSDK-13301] README: explain why Python version drops are minor releases Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [FSSDK-13301] Make polling-thread failure test independent of CPython wording The test forced a crash with a huge update_interval and matched CPython's OverflowError text, which changed in recent 3.13/3.14/3.15 patch releases. It could also pass without asserting anything if stop() won the race. Mock fetch_datafile to raise a known exception instead, and assert that the exception leaves the thread and is logged once. Also drop the README "Version 5.9+" row: the next version number is decided at release time, so the release PR adds that row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c792eac commit fbfed74

6 files changed

Lines changed: 32 additions & 39 deletions

File tree

‎.github/workflows/python.yml‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ jobs:
6464
fail-fast: false
6565
matrix:
6666
python-version:
67-
- "pypy-3.9"
6867
- "pypy-3.10"
69-
- "3.9"
68+
- "pypy-3.11"
69+
- "pypy-3.12"
7070
- "3.10"
7171
- "3.11"
7272
- "3.12"
73+
- "3.13"
74+
- "3.14"
75+
- "3.15"
7376
steps:
7477
- uses: actions/checkout@v3
7578
with:
@@ -92,13 +95,13 @@ jobs:
9295
fail-fast: false
9396
matrix:
9497
python-version:
95-
# disabled due to librt is not available on this pypy version
96-
# - "pypy-3.9"
97-
# - "pypy-3.10"
98-
# - "3.9"
99-
# - "3.10"
98+
# CPython only: mypy depends on librt, which publishes no PyPy wheels
99+
- "3.10"
100100
- "3.11"
101101
- "3.12"
102+
- "3.13"
103+
- "3.14"
104+
- "3.15"
102105
steps:
103106
- uses: actions/checkout@v3
104107
with:

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Version `4.0+`: Python 3.7+, PyPy 3.7+
2323

2424
Version `3.0+`: Python 2.7+, PyPy 3.4+
2525

26+
Dropping support for an end-of-life Python version doesn't change the SDK's public API, so it ships in a minor release rather than a major one. Each release declares its minimum Python (`python_requires`), so pip on an older Python installs the last compatible release instead. For example, Python 3.8 and 3.9 stay on 5.8.x.
27+
2628
### Install the SDK
2729

2830
The SDK is available through [PyPi](https://pypi.python.org/pypi?name=optimizely-sdk&:action=display).

‎optimizely/event/event_id_normalizer.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@
3737
"""
3838

3939

40-
from sys import version_info
41-
from typing import Any, Optional
42-
43-
if version_info < (3, 10):
44-
from typing_extensions import TypeGuard
45-
else:
46-
from typing import TypeGuard
40+
from typing import Any, Optional, TypeGuard
4741

4842

4943
def is_non_empty_string(value: Any) -> TypeGuard[str]:

‎ruff.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://docs.astral.sh/ruff/configuration/
33

44
line-length = 120
5-
target-version = "py39"
5+
target-version = "py310"
66

77
exclude = [
88
".git",

‎setup.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@
5252
'License :: OSI Approved :: Apache Software License',
5353
'Operating System :: OS Independent',
5454
'Programming Language :: Python',
55-
'Programming Language :: Python :: 3.8',
56-
'Programming Language :: Python :: 3.9',
5755
'Programming Language :: Python :: 3.10',
5856
'Programming Language :: Python :: 3.11',
5957
'Programming Language :: Python :: 3.12',
58+
'Programming Language :: Python :: 3.13',
59+
'Programming Language :: Python :: 3.14',
60+
'Programming Language :: Python :: 3.15',
6061
],
6162
packages=find_packages(exclude=['docs', 'tests']),
6263
extras_require={'test': TEST_REQUIREMENTS},
64+
python_requires='>=3.10',
6365
install_requires=REQUIREMENTS,
6466
tests_require=TEST_REQUIREMENTS,
6567
test_suite='tests',

‎tests/test_config_manager.py‎

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -556,32 +556,24 @@ def test_fetch_datafile__request_exception_raised(self, _):
556556

557557
def test_fetch_datafile__exception_polling_thread_failed(self, _):
558558
""" Test that exception is raised when polling thread stops. """
559-
sdk_key = 'some_key'
560559
mock_logger = mock.Mock()
560+
thread_exceptions = []
561561

562-
test_headers = {'Last-Modified': 'New Time'}
563-
test_datafile = json.dumps(self.config_dict_with_features)
564-
test_response = requests.Response()
565-
test_response.status_code = 200
566-
test_response.headers = test_headers
567-
test_response._content = test_datafile
568-
569-
with mock.patch('requests.Session.get', return_value=test_response):
570-
project_config_manager = config_manager.PollingConfigManager(sdk_key=sdk_key,
571-
logger=mock_logger,
572-
update_interval=12345678912345)
562+
with (
563+
mock.patch('optimizely.config_manager.PollingConfigManager.fetch_datafile',
564+
side_effect=Exception('boom')),
565+
mock.patch('threading.excepthook', side_effect=thread_exceptions.append),
566+
):
567+
project_config_manager = config_manager.PollingConfigManager(sdk_key='some_key', logger=mock_logger)
568+
project_config_manager._polling_thread.join(timeout=2)
573569

574-
project_config_manager.stop()
570+
# the exception is raised out of the polling thread, which stops
571+
self.assertFalse(project_config_manager.is_running)
572+
self.assertEqual(1, len(thread_exceptions))
573+
self.assertEqual('boom', str(thread_exceptions[0].exc_value))
575574

576-
# verify the error log message
577-
log_messages = [args[0] for args, _ in mock_logger.error.call_args_list]
578-
for message in log_messages:
579-
print(message)
580-
# Check for key parts of the error message (version-agnostic for Python 3.11+)
581-
if not ("Thread for background datafile polling failed" in message and
582-
"timestamp too large to convert to C" in message and
583-
"PyTime_t" in message):
584-
assert False
575+
# and it is logged before being raised
576+
mock_logger.error.assert_called_once_with('Thread for background datafile polling failed. Error: boom')
585577

586578
def test_is_running(self, _):
587579
""" Test that polling thread is running after instance of PollingConfigManager is created. """

0 commit comments

Comments
 (0)