mypy/fs,main

This commit is contained in:
Marc Beninca 2024-09-13 23:22:12 +02:00
parent e213285987
commit 114ee61102
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 8 additions and 8 deletions

View file

@ -7,9 +7,9 @@ from pathlib import Path
from rwx import fs from rwx import fs
if __name__ == "__main__": if __name__ == "__main__":
file_path = Path(__file__).resolve() file_path: Path = Path(__file__).resolve()
root_path = file_path.parent root_path: Path = file_path.parent
directory_path = root_path / "tmp" directory_path: Path = root_path / "tmp"
file_path = directory_path / "file" file_path = directory_path / "file"
fs.wipe(directory_path) fs.wipe(directory_path)

View file

@ -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.""" """Empty the file at provided path."""
write(path, "") write(path, "")
@ -47,9 +47,9 @@ def get_path_uuid(path: str) -> str:
return get_mount_uuid(get_path_mount(path)) 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.""" """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: def read_file_bytes(file_path: str) -> bytes:
@ -78,7 +78,7 @@ def wipe(path: Path) -> None:
pass 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.""" """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) file_object.write(text)