Skip to content

Commit 4df11fe

Browse files
committed
fix localpath issue
1 parent 76166f9 commit 4df11fe

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

upath/core.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def __getattribute__(self, item):
7070
method = getattr(fs, item, None)
7171
if method:
7272
awaitable = inspect.isawaitable(lambda args, kwargs: method(*args, **kwargs))
73-
print(item)
74-
print('is awaitable:', awaitable)
7573
return lambda *args, **kwargs: self.argument_upath_self_to_filepath(method)(*args, **kwargs)
7674
else:
7775
raise NotImplementedError(f'{fs.protocol} filesystem has not attribute {item}')
@@ -85,10 +83,8 @@ class PureUniversalPath(PurePath):
8583
class UPath(pathlib.Path):
8684

8785
def __new__(cls, *args, **kwargs):
88-
print('new')
8986
if cls is UPath:
9087
new_args = list(args)
91-
print(new_args)
9288
first_arg = new_args.pop(0)
9389
parsed_url = urllib.parse.urlparse(first_arg)
9490
for key in ['scheme', 'netloc']:
@@ -104,7 +100,10 @@ def __new__(cls, *args, **kwargs):
104100
new_args.insert(0, parsed_url.path)
105101
args = tuple(new_args)
106102

107-
self = cls._from_parts_init(args, init=False)
103+
if cls is UniversalPath:
104+
self = cls._from_parts_init(args, init=False)
105+
else:
106+
self = cls._from_parts(args, init=False)
108107
if not self._flavour.is_supported:
109108
raise NotImplementedError("cannot instantiate %r on your system"
110109
% (cls.__name__,))
@@ -256,21 +255,6 @@ def touch(self, trunicate=True, **kwargs):
256255
self._accessor.touch(self, trunicate=trunicate, **kwargs)
257256

258257
def unlink(self, missing_ok=False):
259-
# async def async_unlink():
260-
# async def rm():
261-
# try:
262-
# await self._accessor.rm_file(self)
263-
# except:
264-
# await self._accessor.rm(self, recursive=False)
265-
266-
267-
# coro = rm()
268-
# done, pending = await asyncio.wait({coro})
269-
# if coro is done:
270-
# return
271-
272-
# print('exists:', self.exists())
273-
274258
if not self.exists():
275259
if not missing_ok:
276260
raise FileNotFoundError
@@ -295,8 +279,6 @@ def rmdir(self, recursive=True):
295279

296280
@classmethod
297281
def _from_parts_init(cls, args, init=False):
298-
print(args)
299-
print(init)
300282
return super()._from_parts(args, init=init)
301283

302284
def _from_parts(self, args, init=True):

upath/tests/test_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pathlib
12
from pathlib import Path
23

34
import pytest
@@ -10,6 +11,10 @@ def pathlib_base(local_testdir):
1011
return Path(local_testdir)
1112

1213

14+
def test_posix_path(local_testdir):
15+
assert isinstance(UPath(local_testdir), pathlib.PosixPath)
16+
17+
1318
class TestUpath:
1419

1520
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)