Skip to content

Commit d75d075

Browse files
refactor: ♻️ rename to properties in read_json() (#169)
# Description Very small fix to use `properties` in `read_json()`. Needs a quick review. ## Checklist - [x] Ran `just run-all` --------- Co-authored-by: martonvago <57952344+martonvago@users.noreply.github.com>
1 parent 8084d54 commit d75d075

File tree

2 files changed

+203
-199
lines changed

2 files changed

+203
-199
lines changed

src/check_datapackage/read_json.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from json import JSONDecodeError, loads
22
from pathlib import Path
3-
from typing import Any
3+
from typing import Any, cast
44

55

66
def read_json(path: Path) -> dict[str, Any]:
@@ -19,7 +19,7 @@ def read_json(path: Path) -> dict[str, Any]:
1919
dictionary.
2020
"""
2121
try:
22-
descriptor: Any = loads(path.read_text())
22+
properties: Any = loads(path.read_text())
2323
except JSONDecodeError as error:
2424
raise JSONDecodeError(
2525
f"The path {path} couldn't be parsed as JSON. Is there a typo or other "
@@ -28,11 +28,11 @@ def read_json(path: Path) -> dict[str, Any]:
2828
pos=error.pos,
2929
) from None # To hide the original traceback
3030

31-
if not isinstance(descriptor, dict):
31+
if not isinstance(properties, dict):
3232
raise TypeError(
3333
f"The file {path} should parse into a Python dictionary (`dict`) "
34-
f"but it converts to the type `{type(descriptor)}`. Is the file "
34+
f"but it converts to the type `{type(properties)}`. Is the file "
3535
"missing a curly bracket `{` at the beginning or `}` at the end?"
36-
)
36+
) from None # To hide the original traceback
3737

38-
return descriptor
38+
return cast(dict[str, Any], properties)

0 commit comments

Comments
 (0)