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

Fix __eq__ _cparts missing #203

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ def _parts(self):
def _parts(self, value):
self.__parts = value

@property
def _cparts(self):
# required for pathlib.Path.__eq__ compatibility on Python <3.12
return self.parts

# === pathlib.PurePath ============================================

def __reduce__(self):
Expand Down
7 changes: 7 additions & 0 deletions upath/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ def test_copy_path_append():
assert str(path / "folder2" / "folder3") == str(copy_path)


def test_compare_to_pathlib_path_ne():
assert UPath("gcs://bucket/folder") != pathlib.Path("gcs://bucket/folder")
assert pathlib.Path("gcs://bucket/folder") != UPath("gcs://bucket/folder")
assert UPath("/bucket/folder") == pathlib.Path("/bucket/folder")
assert pathlib.Path("/bucket/folder") == UPath("/bucket/folder")


@pytest.mark.parametrize(
"urlpath",
[
Expand Down
Loading