Conversation
pathlib writes \server\share\file as file://server/share/file, which fsspec reads as a relative local path. Return file:////server/share/file from WindowsUPath.as_uri so the URI round-trips through UPath.
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.
Closes #557.
WindowsUPath.as_uri()used pathlib's form for UNC paths,file://server/share/file. fsspec reads the part afterfile://as a path, so that URI does not lead back to the share:UPath("file://server/share/file")resolves to<cwd>/server/share/file.As suggested in the issue,
as_uri()now keeps the server in the URI path:Drive-letter paths are unchanged (
file:///c:/...), and percent-encoding still comes from pathlib.Tests:
test_windows_unc_path_as_uri_round_triptotest_core.py(Windows only).test_pathlib_39–312) runPureWindowsPathTest.test_as_uriagainstWindowsUPathand expect pathlib'sfile://some/share/form. I overrode that test inWindowsPathAsPureTestwith thefile:////some/share/expectations and a comment explaining the difference. ThePureWindowsPathtests themselves are untouched.Ran on Windows with Python 3.12:
test_pathlib_312.pypasses, and the new test passes. Both fail without the change. Theas_uritests intest_pathlib_310.pyalso pass on Python 3.10. black and flake8 are clean.