diet-guard/scripts
Krzysztof kuhy Rudnicki cb23f3c09d
Some checks are pending
file-length / file length <= 250 lines (push) Waiting to run
pre-commit / pre-commit (push) Waiting to run
Tests / test (3.10) (push) Waiting to run
Tests / test (3.11) (push) Waiting to run
Tests / test (3.12) (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
Fix check_patch_targets' own fail-open: put the repo root on sys.path
The pre-commit CI job reported all 19 patch targets stale, including ones no
commit in this sweep touched -- the tell that the checker, not the targets,
was broken.

Running it as `python3 scripts/check_patch_targets.py` puts *scripts/* on
sys.path[0], not the repo root. `diet_guard` is not installed in the runner's
environment (CI installs requirements.txt only), so every `import_module` hit
the resolver's `except ImportError: continue` and every target reported
unresolvable. It passed locally because the dev venv has the package on the
path.

That is precisely the fail-open shape this script exists to prevent, in the
script itself: a green-or-red signal that reflects the environment rather than
the code. Two fixes:

- put the repo root on sys.path explicitly, so the checker resolves the same
  way whatever cwd or interpreter invokes it;
- import the package once up front and fail with a distinct message if that
  fails, so "the package will not import" can never again masquerade as
  "every patch target moved".

Reproduced in a clean venv built from requirements.txt: 19 stale before, exit 0
after, and still exactly 1 stale when a target is genuinely broken
(verified by renaming FOOD_LOG_FILE's target).

Verified: 708 Python tests / 100% branch coverage, pre-commit clean, checker
exit 0 under both the dev venv and the clean venv.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RA9ynjqXPnexRQnR5oAuCC
2026-08-15 21:27:24 +02:00
..
bump_patch_version.sh Bump the patch version on every commit 2026-08-09 23:04:17 +02:00
check_file_length.sh Enforce the shared 250-line file cap 2026-08-15 16:35:01 +02:00
check_no_crdt_sync_override.sh Add Google sign-in support for the Firebase sync account 2026-08-12 23:36:10 +02:00
check_patch_targets.py Fix check_patch_targets' own fail-open: put the repo root on sys.path 2026-08-15 21:27:24 +02:00
check_requirements_sync.py Add CI-mirror pre-push gate + requirements-sync check 2026-07-11 17:58:49 +02:00
ci_mirror.sh Stop two keyboard tests hanging, and make the CI mirror mirror CI 2026-08-04 21:50:15 +02:00
setup_mcp.sh Fix pre-existing CI failures (deps, lint, whitespace) 2026-07-10 23:55:56 +02:00