Python version is declared
python/version-declared@v1
The project declares the Python version it is built and run against, and that version is no older than the configured floor.
| Id | python/version-declared |
| Version | v1 |
| Category | python |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | python |
Collectors
This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.
| Collector | Gathers | Inputs it is given |
|---|---|---|
python | The Python project in the project directory: its manifest and build backend, the Python version it asks for, the requirements it declares and which of them are pinned, and the lock files committed beside them. | projectDir |
The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.
Configuration
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "python/version-declared@v1",
"severity": "warning",
"with": {
"projectDir": ".",
"minVersion": "3.9"
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
minVersion | Oldest Python version accepted. A declared version below this is a violation. | 3.9 | GUARDRAIL_INPUT_MINVERSION |
How to fix
Declare the interpreter where the project already declares itself: requires-python = ">=3.12" under [project] in pyproject.toml, or a .python-version file naming the exact release. Without one the interpreter is whatever the runner happens to carry, so a syntax or standard library difference reaches CI rather than the laptop that introduced it.
More in python
python/build-backend-declared. A packaged project names its build backend in[build-system], so it builds the same way everywhere.python/lockfile-committed. The project commits a lock file, so an install of the same commit resolves the same versions.python/single-lockfile. The project commits at most one lock file, so two installers do not each believe they own the environment.