Skip to content

Commit ef8ca71

Browse files
authored
utils.py: read_file - change argument name
Clearer argument name and use of path object
1 parent 7b6b123 commit ef8ca71

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

infrahub_sdk/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,14 @@ def write_to_file(path: Path, value: Any) -> bool:
351351
return written is not None
352352

353353

354-
def read_file(file_name: Path) -> str:
355-
if not file_name.is_file():
356-
raise FileNotValidError(name=str(file_name), message=f"{file_name}: not found at {Path.cwd()}")
354+
def read_file(file_path: Path) -> str:
355+
if not file_path.is_file():
356+
raise FileNotValidError(name=str(file_path.name), message=f"{file_path.name}: not found at {file_path.cwd()}")
357357
try:
358-
with Path.open(file_name, encoding="utf-8") as fobj:
358+
with Path.open(file_path, encoding="utf-8") as fobj:
359359
return fobj.read()
360360
except UnicodeDecodeError as exc:
361-
raise FileNotValidError(name=str(file_name), message=f"Unable to read {file_name} with utf-8 encoding") from exc
361+
raise FileNotValidError(name=str(file_path.name), message=f"Unable to read {file_path.name} with utf-8 encoding") from exc
362362

363363

364364
def get_user_permissions(data: list[dict]) -> dict:

0 commit comments

Comments
 (0)