Skip to content

Commit

Permalink
fix __truediv__
Browse files Browse the repository at this point in the history
  • Loading branch information
normanrz committed Mar 18, 2022
1 parent 14f124d commit 2cfc277
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,22 @@ def _from_parsed_parts(self, drv, root, parts, init=True):
return obj

def __truediv__(self, key):
# Add `/` root if not present
if len(self._parts) == 0:
key = f"{self._root}{key}"
out = self._make_child((key,))
kwargs = out._kwargs.copy()

# Adapted from `PurePath._make_child`
drv, root, parts = self._parse_args((key,))
drv, root, parts = self._flavour.join_parsed_parts(
self._drv, self._root, self._parts, drv, root, parts
)

kwargs = self._kwargs.copy()
kwargs.pop("_url")
out = out.__class__(
out._format_parsed_parts(out._drv, out._root, out._parts),

# Create a new object
out = self.__class__(
self._format_parsed_parts(drv, root, parts),
**kwargs,
)
return out
Expand Down

0 comments on commit 2cfc277

Please sign in to comment.