Skip to content

Don't skip the first part in resolve() when .parts has no anchor - #607

Open
cig13zs wants to merge 1 commit into
fsspec:mainfrom
cig13zs:resolve-without-anchor-part
Open

cig13zs wants to merge 1 commit into
fsspec:mainfrom
cig13zs:resolve-without-anchor-part

Conversation

@cig13zs

@cig13zs cig13zs commented Dec 3, 2026

Copy link
Copy Markdown

UPath.resolve() always treated .parts[0] as the anchor and only normalized the rest. github and webdav paths have no anchor element in .parts, so the first segment was never looked at:

>>> r = UPath("github://fsspec:universal_pathlib@main/")
>>> (r / "../a").resolve().path
'../a'   # before
'a'      # after
>>> (r / "a/../..").resolve().path
'a'      # before
''       # after

resolve() now only splits off .parts[0] when it ends with the separator (which is how parts builds the anchor element), and otherwise resolves all parts on top of self.anchor. Other flavours, including zip/tar/hf where .parts[0] is /, behave as before.

This is the resolve-no-anchor-part xfail in test_special_paths.py; removed it and its KNOWN_ISSUES entry. The full suite passes locally apart from the network-only test_httppath, which fails the same way on main here. pre-commit is clean.

This branch has not been deployed

No deployments
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