Handle config paths on different Windows drives - #3750
Closed
mikemikimike wants to merge 3 commits into
Closed
Conversation
added 3 commits
August 29, 2026 20:10
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #2530.
Background
When the config file is on a different Windows drive than the Git repository,
os.path.relpathraisesValueErrorafter pre-commit changes into the repository root. This prevents commands using an absolute config path from running.Changes
Keep the absolute config path when it cannot be made relative to the repository. Same-drive and relative config behavior is unchanged. A regression test covers the cross-drive failure path.
Validation
python -m pytest tests/main_test.py -q --basetemp D:\\project\\tscodex\\github_pr\\tasks\\precommit-2530-basetemp— 30 passed.python -m ruff check pre_commit/main.py tests/main_test.py— passed.git diff --check— passed.The broader test suite was not collected because the local environment lacks the repository development dependency
re_assert; collection stopped in four test modules before execution.