From 8ffc4e2fda71cf4b5c35cb51f089d6da87f9a780 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 04:59:35 +0000 Subject: [PATCH] chore: remove now-unused REPO_ROOT from require_math_evidence Sourcery-bot housekeeping note on PR #11: REPO_ROOT was only mentioned in comments after the cwd-resolution fix in 61005655 and was no longer used by any logic in this module (other math-first scripts have their own REPO_ROOT constants). Removed it. Folded the rationale that previously lived in the comment above the constant into the _git_toplevel docstring so future readers still see why we don't hardcode the cwd. Co-Authored-By: Allaun Silverfox --- scripts/math-first/require_math_evidence.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/scripts/math-first/require_math_evidence.py b/scripts/math-first/require_math_evidence.py index b0115a09..065c2c79 100755 --- a/scripts/math-first/require_math_evidence.py +++ b/scripts/math-first/require_math_evidence.py @@ -40,23 +40,16 @@ import subprocess import sys from pathlib import Path -# Only used for logging/help -- *not* as the subprocess ``cwd`` for the git -# calls below. Hardcoding the subprocess cwd to this path caused the -# regression test in ``test_require_math_evidence.py`` to pass vacuously -# because the test stages files in a *temp* repo and expects ``git diff -# --cached`` to query that temp repo, not the real one. Pre-commit and CI -# both happen to invoke the script from inside the repo root, so letting -# the git subprocess inherit cwd is correct in every real-world case. -REPO_ROOT = Path(__file__).resolve().parents[2] - def _git_toplevel(cwd: Path | None = None) -> Path: """Return the absolute path of the git working tree containing ``cwd``. Defaults to the current working directory. The script never assumes the - git repo lives at ``REPO_ROOT`` because that would be wrong when the + git repo lives at a hardcoded path because that would be wrong when the script is run from a different working tree -- notably, the temp repo - set up by ``test_require_math_evidence.py``. + set up by ``test_require_math_evidence.py``. Pre-commit and CI both + happen to invoke the script from inside the repo root, so letting the + git subprocess inherit cwd is correct in every real-world case. """ cmd = ["git", "rev-parse", "--show-toplevel"] try: