Skip to content

chore(nox): make Python 3.12 the minimum and stop linting on 3.10 - #14784

Open
iennae wants to merge 1 commit into
mainfrom
chore/nox-py312-baseline
Open

iennae wants to merge 1 commit into
mainfrom
chore/nox-py312-baseline

Conversation

@iennae

@iennae iennae commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Description

Makes Python 3.12 the minimum for the shared nox setup, and stops lint from asking contributors for a Python 3.10 interpreter. 3.10 reached end of life in Oct 2026.

Problem: most samples only tested 3.10 and 3.14, and lint ran on each sample's oldest tested version (3.10). Contributors on 3.12 hit missing-interpreter errors for 3.10 and saw py-3.12 skipped.

Changes

  • noxfile-template.py
    • ALL_VERSIONS is now 3.12–3.15; 3.8–3.11 are removed.
    • The default tests 3.12 + 3.14 (the minimum and the latest stable version).
    • LINTING_VERSION is fixed at 3.12.
    • New OPT_IN_VERSIONS = ["3.15"] and an "opt_in_versions" config key. Existing configs only list the versions they skip, so without this every one of them would start testing 3.15 at once.
  • noxfile_config.py (root default): ignored_versions = ["3.13"], opt_in_versions = [], plus comments on how to opt in to 3.13 and 3.15.
  • .github/workflows/lint.yml and .github/scripts/noxfile-lint.py: the lint job uses Python 3.12. Also fixes two flake8 issues and black formatting that were already in that file.

Leftover version strings in per-sample configs, such as "3.8", are now ignored.

Follow-ups (not in this PR)

  • Per-sample noxfile_config.py files that copied the old default (ignore 3.8, 3.9, 3.11, 3.12, 3.13) now test only 3.14. A follow-up PR will update them to 3.12 + 3.14.
  • Update the Kokoro testing image (.kokoro/docker, .trampolinerc) and remove the old .kokoro/python3.8–3.11 configs.

Verification (local nox 2026.10.20, CPython 3.12.16 / 3.14.10)

Scenario Tested versions Lint version
No local config (template default) 3.12, 3.14 3.12
Root noxfile_config.py 3.12, 3.14 3.12
Copied old config (e.g. alloydb/notebooks) 3.14 3.12
opt_in_versions: ["3.15"] 3.12, 3.14, 3.15 3.12
  • nox -s lint on cloud_scheduler/ created its env with python3.12 and passed.
  • The GitHub lint noxfile (flake8 + black) passes on the changed files.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended. (Tested locally with nox. These are CI and tooling changes, so there's no deployed sample to check.)

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

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 <sigje@google.com>
@iennae
iennae requested review from a team as code owners November 10, 2026 20:44
@product-auto-label product-auto-label Bot added samples Issues that are directly related to samples. api: workflows Issues related to the Workflows API. labels Nov 10, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the supported Python versions across the Nox configuration files, raising the minimum supported version to 3.12 and adding support for up to 3.15. It also introduces an opt-in mechanism for newly released Python versions and sets the linting version to 3.12. A review comment suggests improving the robustness of the version filtering logic in noxfile-template.py by using (TEST_CONFIG.get("opt_in_versions") or []) to prevent potential TypeError exceptions if the configuration explicitly overrides the key to None.

Comment thread noxfile-template.py
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", []))

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.

medium

To make the version filtering more robust and prevent potential TypeError exceptions, use TEST_CONFIG.get("opt_in_versions") or [] instead of TEST_CONFIG.get("opt_in_versions", []). If a user's custom noxfile_config.py explicitly overrides opt_in_versions to None or another falsy value, .get(..., []) would still return None, leading to a TypeError: argument of type 'NoneType' is not iterable during the membership check.

Suggested change
and (v not in OPT_IN_VERSIONS or v in TEST_CONFIG.get("opt_in_versions", []))
and (v not in OPT_IN_VERSIONS or v in (TEST_CONFIG.get("opt_in_versions") or []))

@XrossFox XrossFox left a comment

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.

LGTM

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

Labels

api: workflows Issues related to the Workflows API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants