We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f9f9ad commit 33fb5f5Copy full SHA for 33fb5f5
utils/file_reader.py
@@ -1,18 +1,16 @@
1
import json
2
from pathlib import Path
3
4
-BASE_PATH = Path.cwd().joinpath("data")
+BASE_PATH = Path.cwd() / "data"
5
6
7
-def read_file(file_name):
+def read_file(file_name: str) -> dict:
8
file_path = get_file_with_json_ext(file_name)
9
with open(file_path, mode="r", encoding="utf-8") as f:
10
return json.load(f)
11
12
13
-def get_file_with_json_ext(file_name):
14
- return (
15
- BASE_PATH.joinpath(file_name)
16
- if ".json" in file_name
17
- else BASE_PATH.joinpath(f"{file_name}.json")
18
- )
+def get_file_with_json_ext(file_name: str) -> Path:
+ if not file_name.endswith(".json"):
+ file_name += ".json"
+ return BASE_PATH / file_name
0 commit comments