Skip to content
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

relative_to on GCSPaths does not return a relative path #170

Open
xjmdale opened this issue Jan 19, 2024 · 1 comment
Open

relative_to on GCSPaths does not return a relative path #170

xjmdale opened this issue Jan 19, 2024 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@xjmdale
Copy link

xjmdale commented Jan 19, 2024

Observed behavior:

>>> p1 = upath.UPath("gs://bucket/foo/bar")
>>> p2 = upath.UPath("gs://bucket/foo/bar/baz/quux.txt")
>>> p2.relative_to(p1)
GCSPath('gs://bucket/baz/quux.txt')

The result is not a relative path; it is an absolute path to an alternative GCS object which may or may not exist.

My expectation is that this call would return a fully-relative path to baz/quux.txt. I suppose there is uncertainty is around which path subtype should be returned. baz/quux.txt is not a valid GCS path; but upath.UPath('baz/quux.txt') returns a PosixUPath which also seems wrong.

Python version: 3.11.7
upath version: 0.1.4

@ap-- ap-- added bug Something isn't working documentation Improvements or additions to documentation labels Jan 24, 2024
@ap--
Copy link
Collaborator

ap-- commented Jan 24, 2024

Thank you for reporting!

We need to revisit the implementation of relative_to(). The problem is that relative paths should probably be returned as a custom filesystem independent PurePathBase subclass once we switch to pathlib_abc.

Would you be interested in creating a PR with a test case for your issue?

Cheers,
Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants