Repository navigation
Conversation
UPath.match delegated to full_match, so a relative pattern had to cover
the whole path. pathlib.PurePath.match matches relative patterns from
the right, so UPath('s3://bucket/x/a/b').match('a/b') returned False
where PurePosixPath('/x/a/b').match('a/b') returns True.
This branch has not been deployed
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.
UPath.match()passes the pattern straight tofull_match(), so a relative pattern has to cover the whole path.pathlib.PurePath.match()matches relative patterns from the right instead:The same thing happens with
match("b"),match("*/b")and so on, and for every protocol (memory, s3, gcs, http, ...).Fix:
match()triesfull_match()first, so nothing that matched before stops matching. If that fails and the pattern is relative (it has no leading/and no://), it compares the pattern's segments against the path's last parts, usingfnmatchcaseon each segment. The anchor (bucket/,https://host/) is left out of that comparison, as pathlib does. The**→*handling is unchanged.Tests: added
test_matchto the sharedBaseTestsinupath/tests/cases.py, so it runs for every implementation.DataPathgets an override, as it already does fortest_full_match. The new test fails onmainand passes with this change. These local runs pass: memory, local, data, s3, zip, tar,test_relative.py,test_core.pyand the pathlib suites (1588 + 736). pre-commit is clean.AI-assisted (Claude): I used it to help read the code and draft the test. I reviewed and ran everything myself.