Repository navigation
Load One Copy of the Gate When pr_review.py Dispatches cleanup - #3481
Conversation
Run as a script the gate is __main__, so pr_cleanup's import of pr_review loaded a second copy with its own module state. The dispatch now registers the running module under that name first. A test runs the script under -X importtime and finds no second import. Closes #3461 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues remain, and the changes are covered by a focused regression test.
No open issues 🎉
What changed in this PR
This pull request ensures pr_review.py cleanup reuses the running gate module instead of loading a second copy, preserving shared state and constants.
Changes:
- Registers the executing module under
pr_reviewbefore importingpr_cleanup. - Adds a subprocess regression test verifying that cleanup loads without a duplicate
pr_reviewmodule.
| File | Description |
|---|---|
tests/test_pr_cleanup.py |
Verifies script-mode cleanup imports pr_cleanup without loading a duplicate gate module. |
scripts/pr_review.py |
Aliases the active script module before dispatching cleanup. |
Review effort: Lite
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3481 +/- ##
==========================================
Coverage ? 81.00%
==========================================
Files ? 25
Lines ? 8903
Branches ? 0
==========================================
Hits ? 7212
Misses ? 1691
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
## Summary Promotes the pull requests merged into develop since release 2.0.1181. - [#3479](#3479): `status=COVERAGE_IS_PARTIAL` no longer says the head's own review read fewer files on the carry paths. It leads with the carried reason there and names the remedy that clears it. - [#3480](#3480): `cleanup` re-reads a ref still at the deleted tip for a few seconds before it reports `DELETE_NOT_CONFIRMED`, since the ref read can lag a delete that landed. - [#3481](#3481): `pr_review.py cleanup` loads one copy of the gate rather than a second one under the name `pr_review`. Closes #3424 Closes #3436 Closes #3461 ## Constituent coverage Each change this promotion carries had coverage on its own pull request into develop, at its merged head: | Pull request | Merged head | Coverage | | --- | --- | --- | | [#3479](#3479) | `81ca8d88` | attested local pass at the merged head, base `develop`, and a Copilot table on the merged head naming exactly its 3 changed files, no open findings | | [#3480](#3480) | `2c71411c` | attested local pass at the merged head, base `develop`, and a Copilot table on the merged head naming exactly its 3 changed files, no open findings | | [#3481](#3481) | `1747bd78` | attested local pass at the merged head, base `develop`, and a Copilot table on the merged head naming exactly its 2 changed files, no open findings | 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Answers #3461. Run as a script, the gate is
__main__, sopr_review.py cleanupimportedpr_cleanup, whoseimport pr_review as coreloaded a second copy of the gate with its own memoized readers and constants.cleanupdispatch inmainnow runssys.modules.setdefault("pr_review", sys.modules[__name__])beforeimport pr_cleanup, so that import resolves to the running module. When the gate is imported aspr_review(the tests),setdefaultchanges nothing.pr_review.py cleanupcommand that the host-safety allow rule and thedrive-prandmerge-and-releaseskills name. Moving the six helperspr_cleanuptakes into a new module would also move every test patch point, while adding no safety today:pr_cleanupis the only module importingpr_review.TestCleanupLoadsOneGateruns the real script aspython -X importtime scripts/pr_review.py cleanup --help. It assertspr_cleanupis imported andpr_reviewis not. It fails against the unfixed source. In script mode a second copy can only come from a fresh import under that name, so the import log answers the issue'ssys.modulescondition.Verification
uv run --no-project --with-requirements tests/requirements.txt python -m unittest discover -s tests, 2953 tests run, OK (7 skipped).python3,uv run --script,python -m, import,runpy), every sibling's local imports for the same cycle, and the test's parsing.🤖 Generated with Claude Code