Skip to content

Commit

Permalink
Fixes _kwargs in local sub paths (#158)
Browse files Browse the repository at this point in the history
* wip fixes #156

* _from_parsed_parts

* type: ignore[misc]

* formatting
  • Loading branch information
normanrz committed Oct 19, 2023
1 parent 7e3836d commit 8867a0a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions upath/implementations/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ def _from_parts(cls, args, *, url=None, **kw):
obj._url = SplitResult("", "", str(obj), "", "")
return obj

@classmethod
def _from_parsed_parts(
cls,
drv,
root,
parts,
url=None,
**kwargs: Any,
):
obj = super(UPath, cls)._from_parsed_parts( # type: ignore[misc]
drv, root, parts
)
obj._kwargs = {}
obj._url = SplitResult("", "", str(obj), "", "")
return obj


class WindowsUPath(WindowsPath, UPath):
__slots__ = ()
Expand All @@ -89,3 +105,19 @@ def _from_parts(cls, args, *, url=None, **kw):
obj._kwargs = {}
obj._url = SplitResult("", "", str(obj), "", "")
return obj

@classmethod
def _from_parsed_parts(
cls,
drv,
root,
parts,
url=None,
**kwargs: Any,
):
obj = super(UPath, cls)._from_parsed_parts( # type: ignore[misc]
drv, root, parts
)
obj._kwargs = {}
obj._url = SplitResult("", "", str(obj), "", "")
return obj
5 changes: 5 additions & 0 deletions upath/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ def test_access_to_private_kwargs_and_url(urlpath):
assert isinstance(pth._url, SplitResult)
assert pth._url.scheme == "" or pth._url.scheme in pth.fs.protocol
assert pth._url.path == pth.path
subpth = pth / "foo"
assert subpth._kwargs == {}
assert isinstance(subpth._url, SplitResult)
assert subpth._url.scheme == "" or subpth._url.scheme in subpth.fs.protocol
assert subpth._url.path == subpth.path


def test_copy_path_append_kwargs():
Expand Down

0 comments on commit 8867a0a

Please sign in to comment.