Skip to content

[FSSDK-13301] Raise minimum Python to 3.10, add 3.13–3.15 - #530

Open
Farhan Anjum (FarhanAnjum-opti) wants to merge 3 commits into
masterfrom
farhan-anjum/FSSDK-13301-python-310-min
Open

Farhan Anjum (FarhanAnjum-opti) wants to merge 3 commits into
masterfrom
farhan-anjum/FSSDK-13301-python-310-min

Conversation

@FarhanAnjum-opti

@FarhanAnjum-opti Farhan Anjum (FarhanAnjum-opti) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • event/event_id_normalizer.py: remove the last version_info < (3, 10) guard. Import TypeGuard directly from typing, and drop the typing_extensions fallback, which was never declared in requirements/core.txt.
  • setup.py: add python_requires='>=3.10', and set the classifiers to 3.10–3.15.
  • README.md: add a note that dropping an end-of-life Python version doesn't change the public API, so it ships in a minor release. The requirements row for the new version ("Version X.Y+: Python 3.10+, PyPy 3.10+") is left to the release PR, because the next version number isn't decided yet.
  • tests/test_config_manager.py: rewrite test_fetch_datafile__exception_polling_thread_failed so it doesn't depend on CPython's error wording (see below).
  • ruff.toml: target-version py39 → py310.
  • CI (python.yml):
    • test runs on 3.10–3.15 and pypy-3.10/3.11/3.12. 3.9 and pypy-3.9 are removed.
    • type-check runs on 3.10–3.15. It used to run on only 3.11 and 3.12.

Why: Python 3.8 and 3.9 are end-of-life upstream (since 2024-10 and 2025-10). The latest requests, jsonschema, referencing, urllib3, pytest and mypy all require 3.10+, so the 3.9 CI job was testing older dependency versions than users actually install. 3.13–3.15 were never tested at all. PyPy only goes up to 3.12, so there is no pypy-3.13 or later to add.

What this means for users on 3.8 or 3.9: they stay on 5.8.x. No earlier release declares Requires-Python, and this one declares >=3.10, so pip on 3.8 or 3.9 skips this release and installs the last 5.8.x. The public API is unchanged, so on 3.10+ this is a drop-in upgrade. This change doesn't require a major version on its own. The next release is a minor unless other breaking changes land first; see the ticket for the reasoning.

Why 3.10 is kept, although it reached end-of-life on 2026-10-01

  • It's still the system Python on a supported LTS distro. Ubuntu 22.04's python3 is 3.10, and Canonical keeps patching it until April 2027 (longer for ESM customers). For server-side users on that platform, "end-of-life upstream" doesn't mean unpatched.
  • Nothing in the SDK depends on 3.10. There's no 3.10-specific code. Dropping it would remove only the rpds-py<0.20.0; python_version < '3.11' pin and one CI job.
  • The runtime dependencies still support it. The latest requests, urllib3, jsonschema and referencing all accept 3.10. Only rpds-py (already pinned for 3.10) and coverage (test-only) need 3.11+.
  • Dropping it later is cheap. With python_requires in place, a future drop is a small minor release that pip handles automatically. Dropping 3.9 and 3.10 together would affect more users and remove no code.

3.10 will be dropped in its own minor release when the first of these happens:

  1. requests, urllib3 or jsonschema publishes a release that requires 3.11+, so 3.10 users would stop receiving their fixes;
  2. Ubuntu 22.04 standard support ends (April 2027);
  3. something 3.10-specific breaks CI.

Why the polling-thread test changed

Adding 3.13–3.15 to CI exposed a fragile test. test (3.13), test (3.14) and test (3.15) failed on one test each (1 failed, 1047 passed): test_fetch_datafile__exception_polling_thread_failed.

  • What it checks: if the background polling thread crashes, the SDK logs Thread for background datafile polling failed. Error: ... and re-raises (PollingConfigManager._run).
  • How it forced the crash: it passed a huge update_interval (12345678912345), so threading.Event.wait() raised OverflowError. Then it required CPython's error text to contain "timestamp too large to convert to C".
  • Why it failed: recent CPython patch releases reworded that error. CI's 3.13.18, 3.14.10 and 3.15.2 say timestamp out of range for C PyTime_t. Locally, 3.10–3.12 and also 3.13.0–3.13.14 and 3.14.6 still use the old wording. The SDK behaves the same on all of them: the thread fails and the error is logged. Only the text inside the error, which CPython owns, changed.
  • A second problem: the old test could pass without asserting anything. It called stop() immediately. If that set the stop event before the thread reached wait(), the wait returned at once, nothing was raised or logged, and the assertion loop ran zero times.

The new test mocks fetch_datafile to raise Exception('boom') and captures what leaves the thread with a mocked threading.excepthook. It asserts that:

  • the thread stopped;
  • exactly one exception (boom) was raised out of the thread;
  • the SDK logged Thread for background datafile polling failed. Error: boom exactly once.

It no longer depends on Python's error wording or on thread timing, and the docstring ("exception is raised when polling thread stops") now matches what is actually asserted. As a side effect, pytest no longer emits an "unhandled thread exception" warning for this test.

For the release PR

  • README: add the requirements row for the new version, e.g. "Version X.Y+: Python 3.10+, PyPy 3.10+".
  • CHANGELOG:

Python version support: the minimum supported Python is now 3.10. Python 3.13, 3.14 and 3.15 are now supported. 5.8.x is the last release that supports Python 3.8 and 3.9; pip on those versions will keep installing 5.8.x.

Test plan

  • CI green on every matrix entry: test (3.10–3.15, pypy-3.10/3.11/3.12), type-check (3.10–3.15), lint. (fullstack-prod-suite is excluded: it fails at its "Configure AWS Credentials" step on every run since at least 2026-11-23, unrelated to this PR.)
  • python -m build: the wheel METADATA contains Requires-Python: >=3.10 and the 3.10–3.15 classifiers. pip 26 on Python 3.9.6 refuses it (requires a different Python: 3.9.6 not in '>=3.10').
  • On 3.10:
    • pytest: 1048 passed;
    • mypy . --exclude "tests/testapp" and mypy . --exclude "tests/" --strict pass (mypy 2.4.1);
    • ruff check . passes.
  • pytest on 3.14.6: 1048 passed.
  • The new test ran 10 times each on 3.10.20, 3.13.0 and 3.14.6, and passed all 30 runs.
  • The new test fails if the SDK is broken. With the log line removed: Expected 'error' to be called once. Called 0 times. With the re-raise removed: 1 != 0. (The SDK source was restored after each check.)
  • git grep -nE "version_info|typing_extensions|sys\.version" matches only optimizely/version.py and setup.py.

CI's exact patch versions (3.13.18, 3.14.10, 3.15.2) and PyPy weren't available locally; CI covers them.

Issues

🤖 Generated with Claude Code

- 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>
…ases

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intent: raise the minimum to Python 3.10, add 3.13–3.15 to CI, and make the polling-thread test independent of CPython's error text.

I read the change end to end and found no blocking issues. The rewritten test_fetch_datafile__exception_polling_thread_failed is deterministic. It patches fetch_datafile to raise and threading.excepthook to capture, then asserts the thread stops and the error is logged before it re-raises. TypeGuard imports cleanly on 3.10+, and python_requires, the classifiers and the CI matrix agree. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants