From e1dca3860649e2804b0da8e4e41c90b1e8d06356 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Tue, 10 Nov 2026 20:39:38 +0000 Subject: [PATCH] chore(nox): make Python 3.12 the minimum and stop linting on 3.10 Problem: the shared nox config and the GitHub lint job still targeted Python 3.10, which reached end of life in Oct 2026. Most samples only tested 3.10 and 3.14, and linting used each sample's oldest tested version. So contributors working on 3.12 were asked for a 3.10 interpreter and saw py-3.12 skipped. Solution: - noxfile-template.py: ALL_VERSIONS is now 3.12-3.15 and the default tests 3.12 + 3.14. Lint always runs on 3.12. A new OPT_IN_VERSIONS / "opt_in_versions" setting keeps 3.15 off unless a sample asks for it, because existing configs only list the versions they skip. - noxfile_config.py: the default tests 3.12 + 3.14 and documents how to opt in to 3.13 and 3.15. - .github: the lint job and noxfile-lint.py use 3.12. Also fixes two flake8 issues and black formatting that were already in the file. Old version strings such as "3.8" in per-sample configs are now ignored. Per-sample configs still need updating to test 3.12; that's planned for a follow-up PR. Signed-off-by: Jennifer Davis --- .github/scripts/noxfile-lint.py | 10 ++++++--- .github/workflows/lint.yml | 2 +- noxfile-template.py | 37 ++++++++++++++++++++++++--------- noxfile_config.py | 8 ++++++- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.github/scripts/noxfile-lint.py b/.github/scripts/noxfile-lint.py index c1ce614150d..5423afe3c9d 100644 --- a/.github/scripts/noxfile-lint.py +++ b/.github/scripts/noxfile-lint.py @@ -19,7 +19,7 @@ import nox # Use a stable Python version for running the style utilities -LINTING_VERSION = "3.10" +LINTING_VERSION = "3.12" # Error out if the runner is missing the target python interpreter nox.options.error_on_missing_interpreters = True @@ -33,11 +33,15 @@ def _determine_local_import_names(start_dir: str) -> list[str]: basename for basename, extension in file_ext_pairs if extension == ".py" - or (os.path.isdir(os.path.join(start_dir, basename)) and basename != "__pycache__") + or ( + os.path.isdir(os.path.join(start_dir, basename)) + and basename != "__pycache__" + ) ] except Exception: return [] + # Linting with flake8. # # We ignore the following rules: @@ -88,7 +92,7 @@ def lint(session: nox.sessions.Session) -> None: def blacken(session: nox.sessions.Session) -> None: """Runs black code formatting checks. Honors incremental PR file arguments.""" session.install("black") - + # If explicit target files are passed via posargs, target ONLY those files. if session.posargs: targets = session.posargs diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index feed8cff3d7..fed8222fbb7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Python uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: - python-version: '3.10' + python-version: '3.12' - name: Install nox run: | diff --git a/noxfile-template.py b/noxfile-template.py index 09bd81c1b77..4fdb54d7202 100644 --- a/noxfile-template.py +++ b/noxfile-template.py @@ -23,7 +23,6 @@ import nox - # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING # BE CAREFUL WHEN EDITING THIS FILE! @@ -40,7 +39,12 @@ TEST_CONFIG = { # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7", "3.7", "3.8", "3.10", "3.11", "3.12"], + # By default, samples are tested on the minimum (3.12) and the + # latest stable (3.14) supported Python versions. + "ignored_versions": ["3.13"], + # Newly released Python versions are only tested when a sample + # explicitly opts in, for example: "opt_in_versions": ["3.15"]. + "opt_in_versions": [], # Old samples are opted out of enforcing Python type hints # All new samples should feature them "enforce_type_hints": False, @@ -87,20 +91,33 @@ def get_pytest_env_vars() -> dict[str, str]: return ret -# All versions used to tested samples. -ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] +# All Python versions that samples can be tested on. 3.12 is the minimum +# supported version. +ALL_VERSIONS = ["3.12", "3.13", "3.14", "3.15"] + +# Newly released versions that are only tested when a sample lists them +# in "opt_in_versions". Existing configs only list the versions they +# ignore, so without this a new version would be enabled for all of them. +OPT_IN_VERSIONS = ["3.15"] -# Any default versions that should be ignored. +# Any default versions that should be ignored. Versions that are no +# longer in ALL_VERSIONS (for example "3.8") are safely ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] -TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) +TESTED_VERSIONS = sorted( + [ + v + for v in ALL_VERSIONS + if v not in IGNORED_VERSIONS + and (v not in OPT_IN_VERSIONS or v in TEST_CONFIG.get("opt_in_versions", [])) + ] +) INSTALL_LIBRARY_FROM_SOURCE = bool(os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False)) -# Use the oldest tested Python version for linting (defaults to 3.10) -LINTING_VERSION = "3.10" -if len(TESTED_VERSIONS) > 0: - LINTING_VERSION = TESTED_VERSIONS[0] +# Run style checks on the minimum supported Python version, regardless of +# which versions a sample is tested on, so contributors only need 3.12. +LINTING_VERSION = "3.12" # Error if a python version is missing nox.options.error_on_missing_interpreters = True diff --git a/noxfile_config.py b/noxfile_config.py index 0973c8621c7..162d52a104b 100644 --- a/noxfile_config.py +++ b/noxfile_config.py @@ -22,7 +22,13 @@ TEST_CONFIG_OVERRIDE = { # You can opt out from the test for specific Python versions. - "ignored_versions": ["3.8", "3.9", "3.11", "3.12", "3.13"], + # By default, samples are tested on the minimum (3.12) and the + # latest stable (3.14) supported Python versions. Remove "3.13" + # from this list to also test on 3.13. + "ignored_versions": ["3.13"], + # Newly released Python versions are only tested when listed here, + # for example: "opt_in_versions": ["3.15"]. + "opt_in_versions": [], # Old samples are opted out of enforcing Python type hints # All new samples should feature them "enforce_type_hints": True,