Skip to content

Commit 8867a0a

Browse files
authored
Fixes _kwargs in local sub paths (#158)
* wip fixes #156 * _from_parsed_parts * type: ignore[misc] * formatting
1 parent 7e3836d commit 8867a0a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

upath/implementations/local.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ def _from_parts(cls, args, *, url=None, **kw):
6363
obj._url = SplitResult("", "", str(obj), "", "")
6464
return obj
6565

66+
@classmethod
67+
def _from_parsed_parts(
68+
cls,
69+
drv,
70+
root,
71+
parts,
72+
url=None,
73+
**kwargs: Any,
74+
):
75+
obj = super(UPath, cls)._from_parsed_parts( # type: ignore[misc]
76+
drv, root, parts
77+
)
78+
obj._kwargs = {}
79+
obj._url = SplitResult("", "", str(obj), "", "")
80+
return obj
81+
6682

6783
class WindowsUPath(WindowsPath, UPath):
6884
__slots__ = ()
@@ -89,3 +105,19 @@ def _from_parts(cls, args, *, url=None, **kw):
89105
obj._kwargs = {}
90106
obj._url = SplitResult("", "", str(obj), "", "")
91107
return obj
108+
109+
@classmethod
110+
def _from_parsed_parts(
111+
cls,
112+
drv,
113+
root,
114+
parts,
115+
url=None,
116+
**kwargs: Any,
117+
):
118+
obj = super(UPath, cls)._from_parsed_parts( # type: ignore[misc]
119+
drv, root, parts
120+
)
121+
obj._kwargs = {}
122+
obj._url = SplitResult("", "", str(obj), "", "")
123+
return obj

upath/tests/test_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ def test_access_to_private_kwargs_and_url(urlpath):
259259
assert isinstance(pth._url, SplitResult)
260260
assert pth._url.scheme == "" or pth._url.scheme in pth.fs.protocol
261261
assert pth._url.path == pth.path
262+
subpth = pth / "foo"
263+
assert subpth._kwargs == {}
264+
assert isinstance(subpth._url, SplitResult)
265+
assert subpth._url.scheme == "" or subpth._url.scheme in subpth.fs.protocol
266+
assert subpth._url.path == subpth.path
262267

263268

264269
def test_copy_path_append_kwargs():

0 commit comments

Comments
 (0)