fix(hook): rewrite Windows python module invocations#2327
Open
fengjikui wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2326.
Summary
Windows Python invocations often use
python.exeor a virtualenv interpreter path like.venv/Scripts/python.exe -m pytest. The rewrite registry only matched barepython/python3, so those canonical Windows forms bypassed thertk pytest/rtk mypyrewrite rules.This PR normalizes Python
-minvocations before rule matching by:/and\separators.execase-insensitivelyexclude_commandscan still opt out of either the normalized or original formThe actual rewritten output remains the existing RTK command shape, e.g.
rtk pytest tests/.Validation
cargo fmt --checkcargo test discover::registry::testscargo clippy --all-targets -- -D warningscargo test-> 2148 passed, 8 ignoredpython.exe -m pytest tests/->rtk pytest tests/.venv/Scripts/python.exe -m pytest tests/->rtk pytest tests/C:\repo\.venv\Scripts\python.exe -m pytest tests/->rtk pytest tests/"C:\Users\me\OneDrive - Org\.venv\Scripts\python.exe" -m pytest tests/->rtk pytest tests/The smoke commands returned exit code 3 because
rtk rewriteuses that existing hook protocol for “rewrite available, ask for confirmation” when no explicit allow rule is configured.