Skip to content

Commit f61a574

Browse files
c0llab0rat0rntninja
authored andcommitted
Inline no-op function utils.convert_path
1 parent f00a9cb commit f61a574

File tree

3 files changed

+8
-35
lines changed

3 files changed

+8
-35
lines changed

ipfshttpclient/http_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def download(
718718

719719
fileobj = ReadableStreamWrapper(res) # type: ty.IO[bytes] # type: ignore[assignment]
720720
with tarfile.open(fileobj=fileobj, mode=mode) as tf:
721-
tf.extractall(path=utils.convert_path(target))
721+
tf.extractall(path=target)
722722
finally:
723723
for closable in closables:
724-
closable.close()
724+
closable.close()

ipfshttpclient/multipart.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,6 @@ def __init__(self, directory: ty.Union[ty.AnyStr, utils.PathLike[ty.AnyStr], int
386386
recursive: bool = False) -> None:
387387
self.follow_symlinks = follow_symlinks
388388

389-
if not isinstance(directory, int):
390-
directory = utils.convert_path(directory)
391-
392389
# Create file scanner from parameters
393390
self.scanner = filescanner.walk(
394391
directory,
@@ -401,7 +398,7 @@ def __init__(self, directory: ty.Union[ty.AnyStr, utils.PathLike[ty.AnyStr], int
401398
# Figure out the absolute path of the directory added
402399
self.abspath = None
403400
if not isinstance(directory, int):
404-
self.abspath = os.path.abspath(utils.convert_path(directory))
401+
self.abspath = os.path.abspath(directory)
405402

406403
# Figure out basename of the containing directory
407404
# (normpath is an acceptable approximation here)
@@ -570,7 +567,7 @@ def stream_filesystem_node(
570567
"""
571568
is_dir = False
572569
if isinstance(filepaths, utils.path_types):
573-
is_dir = os.path.isdir(utils.convert_path(filepaths))
570+
is_dir = os.path.isdir(filepaths)
574571
elif isinstance(filepaths, int):
575572
import stat
576573
is_dir = stat.S_ISDIR(os.fstat(filepaths).st_mode)

ipfshttpclient/utils.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,6 @@ def __fspath__(self) -> ty.AnyStr:
4949
path_obj_types = (os.PathLike,)
5050

5151

52-
@ty.overload
53-
def convert_path(path: ty.AnyStr) -> ty.AnyStr:
54-
...
55-
56-
57-
@ty.overload
58-
def convert_path(path: PathLike_str) -> PathLike_str:
59-
...
60-
61-
62-
@ty.overload
63-
def convert_path(path: PathLike_bytes) -> PathLike_bytes:
64-
...
65-
66-
67-
@ty.overload
68-
def convert_path(path: AnyPath) -> AnyPath:
69-
...
70-
71-
72-
def convert_path(path: AnyPath) -> AnyPath:
73-
# Not needed since all system APIs also accept an `os.PathLike`
74-
return path
75-
76-
7752
# work around GH/mypy/mypy#731: no recursive structural types yet
7853
json_primitive_t = ty.Union[bool, float, int, str]
7954
json_value_t = ty.Union[
@@ -143,7 +118,7 @@ def clean_file(file: clean_file_t) -> ty.Tuple[ty.IO[bytes], bool]:
143118
return os.fdopen(file, 'rb', closefd=False), True
144119
elif not hasattr(file, 'read'):
145120
file = ty.cast(path_t, file) # Cannot be ty.IO[bytes] without `.read()`
146-
return open(convert_path(file), 'rb'), True
121+
return open(file, 'rb'), True
147122
else:
148123
file = ty.cast(ty.IO[bytes], file) # Must be ty.IO[bytes]
149124
return file, False
@@ -186,10 +161,11 @@ class return_field(ty.Generic[T]):
186161
The response field to be returned for all invocations
187162
"""
188163
__slots__ = ("field",)
189-
#field: str
164+
165+
field: str
190166

191167
def __init__(self, field: str) -> None:
192-
self.field = field # type: str
168+
self.field = field
193169

194170
def __call__(self, cmd: F) -> ty.Callable[..., T]:
195171
"""Wraps a command so that only a specified field is returned.

0 commit comments

Comments
 (0)