Skip to content

fix: support config files on another Windows drive - #3762

Closed
chen-maker999 wants to merge 1 commit into
pre-commit:mainfrom
chen-maker999:fix/2530-cross-drive-config
Closed

chen-maker999 wants to merge 1 commit into
pre-commit:mainfrom
chen-maker999:fix/2530-cross-drive-config

Conversation

@chen-maker999

Copy link
Copy Markdown

Fixes #2530.

When --config points to a file on a different Windows drive than the repository, os.path.relpath() raises ValueError after pre-commit changes to the repository root. Keep the absolute path when a relative path cannot be computed.

This adds a regression test for the cross-drive case.

Tests:

  • python -m pytest tests/main_test.py -q (30 passed)
  • formatting, import ordering, pyupgrade, autopep8, and flake8 pre-commit hooks passed
  • mypy reports existing platform-specific baseline errors in pre_commit/color.py, pre_commit/xargs.py, and pre_commit/languages/docker.py

@asottile asottile closed this Sep 26, 2026
@pre-commit pre-commit locked as spam and limited conversation to collaborators Sep 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

ValueError on Windows when config is on a different drive than the git repo

2 participants