Skip to content

test: guard the declared Python floor - #20

Merged
casonk merged 1 commit into
mainfrom
test/python-floor-guard
Nov 1, 2026
Merged

casonk merged 1 commit into
mainfrom
test/python-floor-guard

Conversation

@casonk

@casonk casonk commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What

Adds tests/test_python_floor.py: a static check, using only the standard library, that nothing in the repository needs a newer Python than requires-python declares. It rejects datetime.UTC (3.11+), an unguarded tomllib, StrEnum, typing.Self, itertools.batched, ExceptionGroup and syntax newer than the floor. A tomllib import in a try that falls back on ImportError, or in a branch on sys.version_info, is accepted.

Why

Developer machines and agent sessions run a newer Python than CI's oldest job, so these slips pass locally and fail only on the old interpreter (it broke CI in two repositories today). The check runs on any interpreter, so it fails before the push. It is no substitute for CI's oldest-Python job. The same file is used in every repository that declares a floor below 3.11.

Verification

pre-commit run --all-files clean; the new test passes on the current tree.

Static check that nothing needs a newer Python than requires-python.
@casonk
casonk merged commit b99c2a0 into main Nov 1, 2026
5 checks passed
@casonk
casonk deleted the test/python-floor-guard branch November 1, 2026 16:11
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.

1 participant