From 114ee6110208710cdfcb2ed57d9525167daad2fd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:22:12 +0200 Subject: [PATCH] mypy/fs,main --- rwx/__main__.py | 6 +++--- rwx/fs/__init__.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rwx/__main__.py b/rwx/__main__.py index ee4a31b..e19dea1 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -7,9 +7,9 @@ from pathlib import Path from rwx import fs if __name__ == "__main__": - file_path = Path(__file__).resolve() - root_path = file_path.parent - directory_path = root_path / "tmp" + file_path: Path = Path(__file__).resolve() + root_path: Path = file_path.parent + directory_path: Path = root_path / "tmp" file_path = directory_path / "file" fs.wipe(directory_path) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index d1c2732..3902b5a 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -18,7 +18,7 @@ def create_image(file_path: str, size_bytes: int) -> None: ) -def empty_file(path: str) -> None: +def empty_file(path: Path) -> None: """Empty the file at provided path.""" write(path, "") @@ -47,9 +47,9 @@ def get_path_uuid(path: str) -> str: return get_mount_uuid(get_path_mount(path)) -def make_directory(path: str) -> None: +def make_directory(path: Path) -> None: """Make a directory (and its parents) from a path.""" - Path(path).mkdir(exist_ok=True, parents=True) + path.mkdir(exist_ok=True, parents=True) def read_file_bytes(file_path: str) -> bytes: @@ -78,7 +78,7 @@ def wipe(path: Path) -> None: pass -def write(file_path: str, text: str, charset: str = CHARSET) -> None: +def write(file_path: Path, text: str, charset: str = CHARSET) -> None: """Write text into a file.""" - with Path(file_path).open(encoding=charset, mode="w") as file_object: + with file_path.open(encoding=charset, mode="w") as file_object: file_object.write(text)