Skip to content

Fix --package-root tests for Windows and Python 3.13+ #19583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emmatyping
Copy link
Member

This PR should fix the rest of the test failures in #19545.

A change to os.path.relpath in 3.13 seems to have broken the handling of Windows paths beginning with \\. To resolve this issue, we don't split the drive letter off of the path and instead verify the path is on the current drive. If it isn't it will never resolve to the package root because that must be on the same drive as the CWD:

mypy/mypy/main.py

Lines 1571 to 1572 in 5b03024

if drive and drive != current_drive:
parser.error(f"Package root must be on current drive: {drive + root!r}")

Keeping the drive letter allows relpath to properly generate a relative path and make the tests pass.

I need to investigate if the relpath change is a regression in CPython.

A change to relpath in 3.13 seems to have broken
the handling of paths beginning with `\\`.
@emmatyping emmatyping requested a review from ilevkivskyi August 4, 2025 03:51
Copy link
Contributor

github-actions bot commented Aug 4, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant