Skip to content

Commit

Permalink
make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
liyang committed Nov 20, 2024
1 parent 4d65b59 commit 719ac7a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions megfile/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _make_entry(filesystem, info):

class BaseFSSpecPath(URIPath):
protocol: str
filesystem: 'fsspec.AbstractFileSystem'
filesystem: "fsspec.AbstractFileSystem"

Check failure

Code scanning / Pyre

Type Error Error

Undefined or invalid type [11]: Annotation fsspec.AbstractFileSystem is not defined as a type.

def __init__(self, path: PathLike, *other_paths: PathLike):
super().__init__(path, *other_paths)
Expand Down Expand Up @@ -375,7 +375,7 @@ def sync(
self.path_without_protocol, dst_path, recursive=True
)

def rename(self, dst_path: PathLike, overwrite: bool = True) -> "BaseFSSpecPath":
def rename(self, dst_path: PathLike, overwrite: bool = True):
"""
rename file with fsspec
Expand All @@ -384,7 +384,7 @@ def rename(self, dst_path: PathLike, overwrite: bool = True) -> "BaseFSSpecPath"
"""
self.filesystem.mv(self.path_without_protocol, dst_path, recursive=False)

def move(self, dst_path: PathLike, overwrite: bool = True) -> "BaseFSSpecPath":
def move(self, dst_path: PathLike, overwrite: bool = True):
"""
move file/directory with fsspec
Expand All @@ -393,7 +393,7 @@ def move(self, dst_path: PathLike, overwrite: bool = True) -> "BaseFSSpecPath":
"""
self.filesystem.mv(self.path_without_protocol, dst_path, recursive=True)

def unlink(self, missing_ok: bool = False) -> None:
def unlink(self, missing_ok: bool = False):
"""
Remove the file with fsspec
Expand All @@ -403,7 +403,7 @@ def unlink(self, missing_ok: bool = False) -> None:
return
self.filesystem.rm(self.path_without_protocol, recursive=False)

def remove(self, missing_ok: bool = False) -> None:
def remove(self, missing_ok: bool = False):
"""
Remove the file or directory with fsspec
Expand Down
5 changes: 3 additions & 2 deletions megfile/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,13 @@ def __get__( # pyre-ignore[14]
"__set_name__ on it."
)
with self.lock:
name: str = self.attrname # pyre-ignore[9]
# check if another thread filled cache while we awaited lock
# cannot use getattr since it will cause RecursionError
val = cls.__dict__[self.attrname]
val = getattr(cls, name)
if val is self:
val = self.func(cls)
setattr(cls, self.attrname, val)
setattr(cls, name, val)
return val


Expand Down
5 changes: 4 additions & 1 deletion tests/test_smart_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from megfile.fs_path import FSPath
from megfile.hdfs_path import HdfsPath
from megfile.hf_path import HFPath
from megfile.http_path import HttpPath, HttpsPath
from megfile.interfaces import Access
from megfile.s3_path import S3Path
Expand Down Expand Up @@ -58,21 +59,23 @@ def s3_empty_client(mocker):


def test_register_result():
assert len(SmartPath._registered_protocols) == 7
assert len(SmartPath._registered_protocols) == 8
assert S3Path.protocol in SmartPath._registered_protocols
assert FSPath.protocol in SmartPath._registered_protocols
assert HttpPath.protocol in SmartPath._registered_protocols
assert HttpsPath.protocol in SmartPath._registered_protocols
assert StdioPath.protocol in SmartPath._registered_protocols
assert SftpPath.protocol in SmartPath._registered_protocols
assert HdfsPath.protocol in SmartPath._registered_protocols
assert HFPath.protocol in SmartPath._registered_protocols

assert SmartPath._registered_protocols[S3Path.protocol] == S3Path
assert SmartPath._registered_protocols[FSPath.protocol] == FSPath
assert SmartPath._registered_protocols[HttpPath.protocol] == HttpPath
assert SmartPath._registered_protocols[HttpsPath.protocol] == HttpsPath
assert SmartPath._registered_protocols[StdioPath.protocol] == StdioPath
assert SmartPath._registered_protocols[HdfsPath.protocol] == HdfsPath
assert SmartPath._registered_protocols[HFPath.protocol] == HFPath
assert SmartPath.from_uri(FS_TEST_ABSOLUTE_PATH) == SmartPath(FS_TEST_ABSOLUTE_PATH)


Expand Down

0 comments on commit 719ac7a

Please sign in to comment.