-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
use PurePath if path not provided to preserve symlinks #20249
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
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
|
OK, I've tested it and this does, indeed, fix the problem on Windows! This is the old pr, for reference: #20161 |
mypy/test/config.py
Outdated
| this_file_dir = os.path.dirname(PurePath(__file__)) | ||
| PREFIX = os.path.dirname(os.path.dirname(this_file_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I was thinking that we can replace os.path.dirname with the relevant pathlib operation (this_file_dir = (Path(__file__) / '..').resolve()?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there an advantage of doing this over just this_file_dir = (Path(__file__)).resolve().parent ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I just don't know pathlib APIs...
for more information, see https://pre-commit.ci
A5rocks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks better to me! A couple nitpicks but I like this more than what was here before.
@wyattscarpenter could you make sure it still fixes #19956?
FYI I'm unable to resolve comments, so feel free to.
| else: | ||
| this_file_dir = os.path.dirname(os.path.realpath(__file__)) | ||
| this_file_dir = (Path(__file__)).resolve().parent | ||
| PREFIX = os.path.dirname(os.path.dirname(this_file_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can also use .parent. Maybe you'll need to do str(...) to make sure it's a string path at the end, though...
On the other hand, maybe it would be nice to replace all os.path with pathlib.Path native things in this file? Up to you!
|
I wouldn't merge this one yet looks like it breaks on certain windows machines with this one |
Fixes #19956. Updated this_file_dir in conf.py to use PurePath instead of realpath respecting symlink directories in tests.
This is an update of an earlier PR. Decided to use PurePath from UrlLib instead after a commend from A5rocks.
@wyattscarpenter Please retest.