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 7db4103
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 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)

Check warning on line 69 in megfile/fsspec.py

View check run for this annotation

Codecov / codecov/patch

megfile/fsspec.py#L69

Added line #L69 was not covered by tests
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)

Check warning on line 385 in megfile/fsspec.py

View check run for this annotation

Codecov / codecov/patch

megfile/fsspec.py#L385

Added line #L385 was not covered by tests

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)

Check warning on line 394 in megfile/fsspec.py

View check run for this annotation

Codecov / codecov/patch

megfile/fsspec.py#L394

Added line #L394 was not covered by tests

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)

Check warning on line 404 in megfile/fsspec.py

View check run for this annotation

Codecov / codecov/patch

megfile/fsspec.py#L402-L404

Added lines #L402 - L404 were not covered by tests

def remove(self, missing_ok: bool = False) -> None:
def remove(self, missing_ok: bool = False):
"""
Remove the file or directory with fsspec
Expand Down Expand Up @@ -456,7 +456,7 @@ def create_generator():
FileNotFoundError("No match any file in: %r" % self.path_with_protocol),
)

def scandir(self) -> Iterator[FileEntry]:
def scandir(self, followlinks: bool = False) -> Iterator[FileEntry]:
"""
Get all content of given file path.
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 7db4103

Please sign in to comment.