diff --git a/upath/core.py b/upath/core.py index bea2eba..ec0a575 100644 --- a/upath/core.py +++ b/upath/core.py @@ -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): diff --git a/upath/tests/test_core.py b/upath/tests/test_core.py index d9a42d6..71a53ae 100644 --- a/upath/tests/test_core.py +++ b/upath/tests/test_core.py @@ -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", [