From ffe3391b2dd5508712ad4fd08a07ed51ded80c2b Mon Sep 17 00:00:00 2001 From: JerrettDavis Date: Thu, 16 Apr 2026 17:59:18 -0500 Subject: [PATCH] fix: restore CI compatibility for release versioning Lazy-load tomllib so Python 3.10 test collection succeeds, and apply the repo formatter change required by the 3.12 lint job. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- headroom/proxy/server.py | 3 ++- headroom/release_version.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/headroom/proxy/server.py b/headroom/proxy/server.py index 3b5729337..4b74034da 100644 --- a/headroom/proxy/server.py +++ b/headroom/proxy/server.py @@ -2532,7 +2532,8 @@ if __name__ == "__main__": "--openai-api-url", help=f"Custom OpenAI API URL (default: {HeadroomProxy.OPENAI_API_URL})" ) parser.add_argument( - "--anthropic-api-url", help=f"Custom Anthropic API URL (default: {HeadroomProxy.ANTHROPIC_API_URL})" + "--anthropic-api-url", + help=f"Custom Anthropic API URL (default: {HeadroomProxy.ANTHROPIC_API_URL})", ) # Backend (anthropic direct, bedrock, openrouter, anyllm, or litellm-) diff --git a/headroom/release_version.py b/headroom/release_version.py index 00dccadf7..076fb75cb 100644 --- a/headroom/release_version.py +++ b/headroom/release_version.py @@ -9,8 +9,6 @@ from collections.abc import Sequence from dataclasses import dataclass, replace from pathlib import Path -import tomllib - SEMVER_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)$") RELEASE_TAG_RE = re.compile(r"^v(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?$") @@ -126,6 +124,11 @@ def compute_release_version( def get_canonical_version(root: Path) -> str: """Read the canonical project version from pyproject.toml.""" + try: + import tomllib + except ModuleNotFoundError: # pragma: no cover - Python 3.10 compatibility + import tomli as tomllib + with open(root / "pyproject.toml", "rb") as file: data = tomllib.load(file) return data["project"]["version"]