Files
kevinveenbirkenbachandClaude Opus 5.5 5322c96891 fix(web-app-docs): hold the python base inside requires-python
PR 1448 let the image updater move the docs base to python:3.15-slim, where pip refuses infinito-nexus (requires-python >=3.11,<3.15), so every deploy that builds docs failed. docs now pins python:3.14-slim and sets follow: requires-python; followed_tags then proposes only tags whose Python 3 minor requires-python admits.

One reader, utils/requires_python.py, serves the updater filter, the new requires_python lookup (dev-python gets the same string the old regex produced), the ansible cap test and a lint that makes every role image pip-installing core from the repository declare that follow and pin a supported base.

MEDUSA finding MEDUSA-FTSC-SCAN-089 on utils/requires_python.py:25 (ModelAttackScanner, RLHF reward hacking) accepted as a reviewed false positive: the function only parses the repository own requires-python spec.

🎯 Fix: 93 %
💥 Break: 3 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 90
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 00:54:50 +00:00

38 lines
1.0 KiB
Python

"""The Python 3 minors core runs on, read from ``requires-python`` of pyproject.toml."""
from __future__ import annotations
import re
import tomllib
from pathlib import Path
from utils.cache.files import PROJECT_ROOT, read_text
FOLLOW = "requires-python"
_RANGE = re.compile(r"^>=3\.(\d+),<3\.(\d+)$")
def requires_python(root: Path = PROJECT_ROOT) -> str:
"""Return the ``requires-python`` spec of ``<root>/pyproject.toml``.
Args:
root: the repository root holding pyproject.toml.
"""
pyproject = tomllib.loads(read_text(str(Path(root) / "pyproject.toml")))
return str(pyproject["project"]["requires-python"])
def supported_minors(spec: str) -> range:
"""Return the Python 3 minors a ``>=3.X,<3.Y`` spec admits.
Args:
spec: the ``requires-python`` value.
Raises:
ValueError: the spec has another shape.
"""
match = _RANGE.fullmatch(spec)
if match is None:
raise ValueError(f"requires-python {spec!r} must read >=3.X,<3.Y")
return range(int(match[1]), int(match[2]))