Skip to content

Commit

Permalink
refactor: replace os.path with pathlib.Path in helper.py
Browse files Browse the repository at this point in the history
Make the path building expression less convoluted and more readable.
  • Loading branch information
mmtj committed Oct 31, 2023
1 parent 75a1592 commit 71a98ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pywhat/helper.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit 71a98ea

Please sign in to comment.