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)