From 62f870604c5563ea78a82f719b4048d7cf1d2133 Mon Sep 17 00:00:00 2001 From: Jake Fineman Date: Tue, 8 Sep 2026 18:03:18 -0400 Subject: [PATCH] fix(ci): tomllib is not stdlib below Python 3.11, but the test matrix runs 3.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit python-tests.yml added a pytest matrix of 3.9/3.12/3.13, and pytest collects every test file regardless of which one is under test. tests/test_check_drift.py and tests/test_ga_common_github_auth.py both import (directly or transitively) scripts/release/check_drift.py and scripts/ga/ga_common.py, both of which did `import tomllib` unconditionally — a module stdlib only from Python 3.11. Collection failed with ModuleNotFoundError on the 3.9 leg, interrupting the whole run (2 errors during collection, 0 tests executed on that leg). pyproject.toml already declares `tomli>=2.0.0; python_version < '3.11'` as a dev dependency, and tests/test_packaging.py already uses the try/except ModuleNotFoundError fallback — this applies the same, already- established pattern to the two release-tooling modules that were missing it. --- scripts/ga/ga_common.py | 5 ++++- scripts/release/check_drift.py | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/ga/ga_common.py b/scripts/ga/ga_common.py index 4bc7835..f525260 100644 --- a/scripts/ga/ga_common.py +++ b/scripts/ga/ga_common.py @@ -17,7 +17,10 @@ from pathlib import Path from urllib.parse import quote, urlsplit -import tomllib +try: # tomllib is stdlib from 3.11; `tomli` is a dev dependency below that (see pyproject.toml). + import tomllib +except ModuleNotFoundError: + import tomli as tomllib REPO_ROOT = Path(__file__).resolve().parent.parent.parent USER_AGENT = "wave-ga-evidence-sdk-python/1.0" diff --git a/scripts/release/check_drift.py b/scripts/release/check_drift.py index 75874d4..b67f21a 100644 --- a/scripts/release/check_drift.py +++ b/scripts/release/check_drift.py @@ -26,8 +26,9 @@ 2 a source was unreadable (network error, bad JSON, git/gh failure) -- an unreadable registry is NEVER treated as "in sync" -Stdlib + `git`/`gh` CLI only. No third-party imports so this runs identically -in CI and on a laptop with nothing but Python 3.11+ and the GitHub CLI. +Stdlib + `git`/`gh` CLI only (plus `tomli` as a dev dependency below Python 3.11, where `tomllib` +isn't stdlib yet) so this runs identically in CI and on a laptop with the GitHub CLI, across the +full `requires-python = ">=3.9"` matrix this package supports. """ from __future__ import annotations @@ -40,7 +41,10 @@ import urllib.request from pathlib import Path -import tomllib +try: # tomllib is stdlib from 3.11; `tomli` is a dev dependency below that (see pyproject.toml). + import tomllib +except ModuleNotFoundError: + import tomli as tomllib PYPI_PROJECT = "wave-sdk" GITHUB_REPO = "wave-av/sdk-python"