From 44b05ddfdba3f7e2238e726283c1b994c8454b04 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Sat, 21 Feb 2026 16:27:13 -0800 Subject: [PATCH 1/2] fix: update macros.py to use setuptools_scm for dynamic versioning After migrating from bump2version to setuptools_scm, project.version is no longer a static field in pyproject.toml. Use get_version() from setuptools_scm instead, and add it to docs optional dependencies so the CI docs build has access to it. --- macros.py | 17 ++++++----------- pyproject.toml | 1 + 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/macros.py b/macros.py index c5466c5..eca1700 100644 --- a/macros.py +++ b/macros.py @@ -1,25 +1,20 @@ from __future__ import annotations -import tomllib from pathlib import Path from typing import Any +from setuptools_scm import get_version -def _load_version(pyproject_path: Path) -> str: - """Return project version string from pyproject.toml.""" - with pyproject_path.open("rb") as pyproject_file: - data = tomllib.load(pyproject_file) - project = data.get("project", {}) - version = project.get("version") - if not isinstance(version, str): - raise ValueError("project.version must be defined in pyproject.toml") - return version + +def _load_version(root: Path) -> str: + """Return project version string using setuptools_scm.""" + return get_version(root=str(root)) def define_env(env: Any) -> None: """Expose project version to MkDocs macros and theme configuration.""" root = Path(__file__).resolve().parent - version = _load_version(root / "pyproject.toml") + version = _load_version(root) env.variables["project_version"] = version extra = env.conf.get("extra") or {} extra["version"] = version diff --git a/pyproject.toml b/pyproject.toml index 1df6b34..1816dcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,7 @@ docs = [ "mkdocs-material", "mkdocstrings[python]", "mkdocs-macros-plugin", + "setuptools_scm>=8.0", ] [project.scripts] From d9c2f2c0fee9134bbc1391decd86e2c5048bacef Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Sat, 21 Feb 2026 16:50:52 -0800 Subject: [PATCH 2/2] fix: exclude macros.py from basedpyright type checking macros.py is a MkDocs plugin file (not library source) and imports setuptools_scm which is not installed in the type-check environment. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1816dcb..ef0e3e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,7 @@ typeCheckingMode = "standard" reportAny = false reportExplicitAny = false reportUnusedCallResult = false -exclude = ["src/alpha_hwr/*_baseline.py"] +exclude = ["src/alpha_hwr/*_baseline.py", "macros.py"] [tool.mypy] ignore_missing_imports = true