Skip to content

fix: run the link checkers from outside BeautifulRepo and under python -I - #89

Merged
drevendev merged 1 commit into
masterfrom
beautifulrepo/tool-root-isolation-20261022
Oct 22, 2026
Merged

drevendev merged 1 commit into
masterfrom
beautifulrepo/tool-root-isolation-20261022

Conversation

@drevendev

Copy link
Copy Markdown
Owner

Reader problem and change

To run BeautifulRepo's checkers from an installed copy (an agent plugin, a vendored checkout) against another repository, two bugs had to be fixed:

  1. python -I tools/html_navigation.py crashed with ModuleNotFoundError: No module named 'docs_links'. Isolated mode drops the script directory from sys.path, so the plain sibling import failed. The module is now loaded by path from Path(__file__), and an already imported copy of the same file is reused, so tests that import both modules still share one.
  2. docs_links.py and html_navigation.py checked the wrong repository by default. --root defaulted to the parent of tools/, so cd other-repo && python /path/to/BeautifulRepo/tools/docs_links.py silently checked BeautifulRepo and printed OK. Both now default to the current directory, like repo_audit.py.

Commands documented "from the repository root" behave exactly as before, and action.yml already passes --root. catalog.py keeps its defaults, because it manages BeautifulRepo's own catalog rather than a target repository.

Closes #68

Evidence

  • New tests/test_tool_invocation.py runs every checker with python -I from a temporary foreign repository, with and without --root. Against the previous tools it fails 3 times (both default-root cases and the -I case). Against this branch it passes.
  • tools/README.md documents the default and shows python -I usage from another repository. A CHANGELOG entry is under Unreleased.

Verification

  • Catalog validation and generated-view check completed.
  • python -m unittest discover -s tests → Ran 233 tests ... OK (skipped=5) on Windows 11 / Python 3.14.7.
  • docs_links.py, html_navigation.py (also with -I) and repo_audit.py . all pass on the repository.
  • Accessibility and visual checks: not applicable.

Limitations

The default change affects only someone who ran the link checkers from a different directory and expected BeautifulRepo to be checked. That case is now an explicit --root.

Part of epic #86, and a prerequisite for #69.

🤖 Generated with Claude Code

…n -I

- html_navigation.py loaded docs_links with a plain sibling import, which
  fails under `python -I` because isolated mode drops the script directory
  from sys.path. It now loads the sibling by path, reusing an already
  imported copy of the same file.
- docs_links.py and html_navigation.py defaulted --root to the parent of
  tools/, so a run from an installed copy without --root silently checked
  BeautifulRepo itself and printed OK. They now default to the current
  directory, like repo_audit.py. Commands run from the repository root
  behave as before; action.yml already passes --root.
- New tests run every checker with -I from a foreign working directory and
  fail on the previous code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@drevendev
drevendev merged commit 29b9947 into master Oct 22, 2026
5 checks passed
@drevendev
drevendev deleted the beautifulrepo/tool-root-isolation-20261022 branch October 22, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools: html_navigation.py fails under python -I, and the link checkers default to their own checkout

1 participant