Skip to content

Stop pr_review.py cleanup From Loading a Second Copy of the Gate #3461

Closed

Description

@ptr727

Context

scripts/pr_cleanup.py does import pr_review as core, and scripts/pr_review.py imports pr_cleanup for its cleanup subcommand. When the gate runs as a script it is __main__, so pr_review.py cleanup loads a second copy of the gate under the name pr_review. That copy holds its own module state: its memoized readers and every constant a test patches. Today control passes straight to pr_cleanup.main, so nothing reads both copies. A future path that sets state on one copy and reads it from the other would disagree silently.

Suggested Change

Move what pr_cleanup.py takes from the gate (in_scope, parsed_json, reread, utf8_console, UNSAFE_REF, DOT_SEGMENT) to a module both import, so neither imports the other. Alternatively, make cleanup a separate entry point that the gate does not import.

Done When

Running pr_review.py cleanup loads one copy of each module, and a test asserts that sys.modules holds no second pr_review after the subcommand dispatches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions