Skip to content

Commit

Permalink
Fix rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Koncopd committed Jun 17, 2024
1 parent 68f8369 commit 35b2c75
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,11 +1010,15 @@ def rename(
maxdepth: int | None = None,
**kwargs: Any,
) -> UPath: # fixme: non-standard
target_: UPath
if not isinstance(target, UPath):
target_ = self.parent.joinpath(target).resolve()
else:
target_ = target
target_ = UPath(target)
if target_.protocol and target_.protocol != self.protocol:
raise ValueError(
f"expected protocol {self.protocol!r}, got: {target_.protocol!r}"
)
target_ = target_.resolve()
parent = self.parent.resolve()
if not target_.is_relative_to(str(parent)):
target_ = parent.joinpath(target_)
self.fs.mv(
self.path,
target_.path,
Expand Down

0 comments on commit 35b2c75

Please sign in to comment.