From aa1f06c20fc756227b18459c6d1883fd700df140 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:13:16 +0200 Subject: [PATCH] lint/fs --- rwx/fs/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 9189778..64a8483 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -56,15 +56,16 @@ def read_file(file_path: str): return file_object.read() -def read_file_lines(file_path: str, charset=CHARSET): +def read_file_lines(file_path: str, charset:str=CHARSET): return read_file_text(file_path).split(os.linesep) -def read_file_text(file_path: str, charset=CHARSET): +def read_file_text(file_path: str, charset:str=CHARSET): return read_file(file_path).decode(charset) -def wipe(path: str): +def wipe(path: str) -> None: + """Wipe provided path, whether directory or file.""" try: shutil.rmtree(path) except NotADirectoryError: @@ -73,6 +74,7 @@ def wipe(path: str): pass -def write(file_path: str, text: str, charset=CHARSET): +def write(file_path: str, text: str, charset:str=CHARSET) -> None: + """Write text into a file.""" with open(file_path, "bw") as file_object: file_object.write(text.encode(charset))