From 3b730681d54ed9f4a833ed8097efed87924db261 Mon Sep 17 00:00:00 2001 From: Farhan Anjum Date: Thu, 26 Nov 2026 15:20:59 +0600 Subject: [PATCH 1/3] =?UTF-8?q?[FSSDK-13301]=20Raise=20minimum=20Python=20?= =?UTF-8?q?to=203.10,=20add=203.13=E2=80=933.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .github/workflows/python.yml | 17 ++++++++++------- README.md | 4 ++++ optimizely/event/event_id_normalizer.py | 8 +------- ruff.toml | 2 +- setup.py | 6 ++++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 830ca0f4..5283b586 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -64,12 +64,15 @@ jobs: fail-fast: false matrix: python-version: - - "pypy-3.9" - "pypy-3.10" - - "3.9" + - "pypy-3.11" + - "pypy-3.12" - "3.10" - "3.11" - "3.12" + - "3.13" + - "3.14" + - "3.15" steps: - uses: actions/checkout@v3 with: @@ -92,13 +95,13 @@ jobs: fail-fast: false matrix: python-version: - # disabled due to librt is not available on this pypy version - # - "pypy-3.9" - # - "pypy-3.10" - # - "3.9" - # - "3.10" + # CPython only: mypy depends on librt, which publishes no PyPy wheels + - "3.10" - "3.11" - "3.12" + - "3.13" + - "3.14" + - "3.15" steps: - uses: actions/checkout@v3 with: diff --git a/README.md b/README.md index e0aeafb6..5d9cf0e0 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,16 @@ Refer to the [Python SDK's developer documentation](https://docs.developers.opti ### Requirements +Version `5.9+`: Python 3.10+, PyPy 3.10+ + Version `5.0+`: Python 3.8+, PyPy 3.8+ Version `4.0+`: Python 3.7+, PyPy 3.7+ Version `3.0+`: Python 2.7+, PyPy 3.4+ +Python versions that reach end-of-life upstream may continue to work, but support for them can be dropped in any minor release. When that happens, `python_requires` ensures pip keeps older Pythons on the last compatible release. + ### Install the SDK The SDK is available through [PyPi](https://pypi.python.org/pypi?name=optimizely-sdk&:action=display). diff --git a/optimizely/event/event_id_normalizer.py b/optimizely/event/event_id_normalizer.py index f2d4235d..5bf7103e 100644 --- a/optimizely/event/event_id_normalizer.py +++ b/optimizely/event/event_id_normalizer.py @@ -37,13 +37,7 @@ """ -from sys import version_info -from typing import Any, Optional - -if version_info < (3, 10): - from typing_extensions import TypeGuard -else: - from typing import TypeGuard +from typing import Any, Optional, TypeGuard def is_non_empty_string(value: Any) -> TypeGuard[str]: diff --git a/ruff.toml b/ruff.toml index 5365a7b4..289c7c59 100644 --- a/ruff.toml +++ b/ruff.toml @@ -2,7 +2,7 @@ # https://docs.astral.sh/ruff/configuration/ line-length = 120 -target-version = "py39" +target-version = "py310" exclude = [ ".git", diff --git a/setup.py b/setup.py index 18c9d1d7..8aac986a 100644 --- a/setup.py +++ b/setup.py @@ -52,14 +52,16 @@ 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', + 'Programming Language :: Python :: 3.15', ], packages=find_packages(exclude=['docs', 'tests']), extras_require={'test': TEST_REQUIREMENTS}, + python_requires='>=3.10', install_requires=REQUIREMENTS, tests_require=TEST_REQUIREMENTS, test_suite='tests', From 7a7fcab4de4820268f823008b7bcec73539b7126 Mon Sep 17 00:00:00 2001 From: Farhan Anjum Date: Thu, 26 Nov 2026 15:27:37 +0600 Subject: [PATCH 2/3] [FSSDK-13301] README: explain why Python version drops are minor releases Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d9cf0e0..dd6b2a23 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Version `4.0+`: Python 3.7+, PyPy 3.7+ Version `3.0+`: Python 2.7+, PyPy 3.4+ -Python versions that reach end-of-life upstream may continue to work, but support for them can be dropped in any minor release. When that happens, `python_requires` ensures pip keeps older Pythons on the last compatible release. +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. ### Install the SDK From 27455d71cd7d1c13f4ad5112a9d9d74b747a1e36 Mon Sep 17 00:00:00 2001 From: Farhan Anjum Date: Thu, 26 Nov 2026 15:51:55 +0600 Subject: [PATCH 3/3] [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 --- README.md | 2 -- tests/test_config_manager.py | 36 ++++++++++++++---------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index dd6b2a23..13df31e3 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ Refer to the [Python SDK's developer documentation](https://docs.developers.opti ### Requirements -Version `5.9+`: Python 3.10+, PyPy 3.10+ - Version `5.0+`: Python 3.8+, PyPy 3.8+ Version `4.0+`: Python 3.7+, PyPy 3.7+ diff --git a/tests/test_config_manager.py b/tests/test_config_manager.py index 8fa19693..96bb5ecb 100644 --- a/tests/test_config_manager.py +++ b/tests/test_config_manager.py @@ -556,32 +556,24 @@ def test_fetch_datafile__request_exception_raised(self, _): def test_fetch_datafile__exception_polling_thread_failed(self, _): """ Test that exception is raised when polling thread stops. """ - sdk_key = 'some_key' mock_logger = mock.Mock() + thread_exceptions = [] - test_headers = {'Last-Modified': 'New Time'} - test_datafile = json.dumps(self.config_dict_with_features) - test_response = requests.Response() - test_response.status_code = 200 - test_response.headers = test_headers - test_response._content = test_datafile - - with mock.patch('requests.Session.get', return_value=test_response): - project_config_manager = config_manager.PollingConfigManager(sdk_key=sdk_key, - logger=mock_logger, - update_interval=12345678912345) + with ( + mock.patch('optimizely.config_manager.PollingConfigManager.fetch_datafile', + side_effect=Exception('boom')), + mock.patch('threading.excepthook', side_effect=thread_exceptions.append), + ): + project_config_manager = config_manager.PollingConfigManager(sdk_key='some_key', logger=mock_logger) + project_config_manager._polling_thread.join(timeout=2) - project_config_manager.stop() + # the exception is raised out of the polling thread, which stops + self.assertFalse(project_config_manager.is_running) + self.assertEqual(1, len(thread_exceptions)) + self.assertEqual('boom', str(thread_exceptions[0].exc_value)) - # verify the error log message - log_messages = [args[0] for args, _ in mock_logger.error.call_args_list] - for message in log_messages: - print(message) - # Check for key parts of the error message (version-agnostic for Python 3.11+) - if not ("Thread for background datafile polling failed" in message and - "timestamp too large to convert to C" in message and - "PyTime_t" in message): - assert False + # and it is logged before being raised + mock_logger.error.assert_called_once_with('Thread for background datafile polling failed. Error: boom') def test_is_running(self, _): """ Test that polling thread is running after instance of PollingConfigManager is created. """