Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f5b287e
tests: add relative path tests
ap-- Sep 21, 2025
04b2ab8
upath: initial relative path implementation
ap-- Sep 21, 2025
8f95ea6
tests: adjust relative_to tests
ap-- Sep 21, 2025
067bdf7
Various fixes for windows and typesafety
ap-- Sep 21, 2025
66b8d2b
upath: don't make cwd() abstract in mixin
ap-- Sep 26, 2025
07bd615
upath: as_uri() for relative paths
ap-- Sep 26, 2025
4eb200b
upath: add tests for file access on relative paths
ap-- Sep 26, 2025
78475a2
upath: relative path drive,root,anchor fixes
ap-- Sep 27, 2025
0aff83d
upath: more relative path tests
ap-- Sep 27, 2025
4e2c1c9
Merge remote-tracking branch 'origin/main' into upath-relative-paths
ap-- Sep 27, 2025
dce202b
tests: fix typo in relative path suffixes test
ap-- Sep 27, 2025
42a1188
tests: add .parent tests for relative paths
ap-- Sep 27, 2025
f2ef592
upath: repr for relative paths
ap-- Sep 27, 2025
cb4ce59
tests: relpath tests for parent(s), protocol, storage_options, path, …
ap-- Sep 28, 2025
ea2ef27
tests: parser and resolve tests
ap-- Sep 28, 2025
89d755e
tests: add tests for relative path .match
ap-- Sep 28, 2025
3db280b
tests: add tests for joinpath
ap-- Sep 28, 2025
78e7496
upath: return dynamically created subclasses for untested protocols
ap-- Sep 28, 2025
ba349a0
upath: fix relative-path support for with_segments
ap-- Sep 28, 2025
9f30f54
upath: fix __vfspath__ for relative paths
ap-- Sep 28, 2025
884a9f8
upath: fix parent for relative paths
ap-- Sep 28, 2025
d8e0a3c
upath: .parents implementation for relative paths
ap-- Sep 28, 2025
c42e84d
upath: fix FilePath.cwd() and FilePath.home()
ap-- Sep 28, 2025
1792ab1
upath: fix pickling of dynamically created classes
ap-- Sep 28, 2025
a4160a5
tests: fix .cwd and .home tests in core
ap-- Sep 28, 2025
d32bb4c
upath: fix remaining relative path tests
ap-- Sep 28, 2025
7d24fe7
tests: fix windows path separator comparisons
ap-- Sep 28, 2025
cfe2228
tests: fix file uri comparison
ap-- Sep 28, 2025
3a28728
tests: relative joinpath fix windows separator comparison
ap-- Sep 28, 2025
cdc0ee6
upath.implementations.cloud: fix GCSPath.exists() for gcsfs<2025.5.0
ap-- Sep 28, 2025
5186725
tests: add mulitple join tests for different local/fsspec combinations
ap-- Sep 28, 2025
6998a2d
upath: fix joinpath for relative upaths
ap-- Sep 28, 2025
866af94
upath: fix local joinpath stringification
ap-- Sep 28, 2025
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
7 changes: 5 additions & 2 deletions upath/_flavour.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from fsspec.registry import registry as _class_registry
from fsspec.spec import AbstractFileSystem

import upath
from upath._flavour_sources import FileSystemFlavourBase
from upath._flavour_sources import flavour_registry
from upath._protocol import get_upath_protocol
Expand Down Expand Up @@ -239,12 +240,14 @@ def local_file(self) -> bool:
def stringify_path(pth: PathOrStr) -> str:
if isinstance(pth, str):
out = pth
elif isinstance(pth, upath.UPath) and not pth.is_absolute():
out = str(pth)
elif getattr(pth, "__fspath__", None) is not None:
assert hasattr(pth, "__fspath__")
out = pth.__fspath__()
elif isinstance(pth, os.PathLike):
out = str(pth)
elif hasattr(pth, "path"): # type: ignore[unreachable]
elif isinstance(pth, upath.UPath) and pth.is_absolute():
out = pth.path
else:
out = str(pth)
Expand Down Expand Up @@ -288,7 +291,7 @@ def join(self, path: PathOrStr, *paths: PathOrStr) -> str:
if self.local_file:
return os.path.join(
self.strip_protocol(path),
*paths, # type: ignore[arg-type]
*map(self.stringify_path, paths),
)
if self.netloc_is_anchor:
drv, p0 = self.splitdrive(path)
Expand Down
5 changes: 5 additions & 0 deletions upath/_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ def compatible_protocol(
*args: str | os.PathLike[str] | PurePath | JoinablePath,
) -> bool:
"""check if UPath protocols are compatible"""
from upath.core import UPath

for arg in args:
if isinstance(arg, UPath) and not arg.is_absolute():
# relative UPath are always compatible
continue
other_protocol = get_upath_protocol(arg)
# consider protocols equivalent if they match up to the first "+"
other_protocol = other_protocol.partition("+")[0]
Expand Down
Loading
Loading