From 71a98ea6e1763e986172b1a2f4e309ae2947d7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mat=C4=9Bjek?= Date: Tue, 31 Oct 2023 22:43:36 +0100 Subject: [PATCH] refactor: replace os.path with pathlib.Path in helper.py Make the path building expression less convoluted and more readable. --- pywhat/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pywhat/helper.py b/pywhat/helper.py index 581ab93..c730fa3 100644 --- a/pywhat/helper.py +++ b/pywhat/helper.py @@ -1,9 +1,9 @@ """Helper utilities""" import collections.abc -import os.path import re from enum import Enum, auto from functools import lru_cache +from pathlib import Path try: import orjson as json @@ -33,7 +33,7 @@ class InvalidTag(Exception): @lru_cache() def read_json(path: str): - fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Data/" + path) + fullpath = Path(__file__).resolve().parent / "Data" / path with open(fullpath, "rb") as myfile: return json.loads(myfile.read())