55import json
66from collections .abc import Callable , Mapping
77from pathlib import Path
8- from typing import cast
9-
10- from src_py_lib .utils .json_types import JSONDict
8+ from typing import Any , cast
119
1210
1311def load_json_cache [Entry ](
1412 path : Path ,
15- parse : Callable [[JSONDict ], Entry ] | None = None ,
13+ parse : Callable [[Any ], Entry ] | None = None ,
1614) -> dict [str , Entry ]:
1715 """Load `path` as a string-keyed cache. Missing files return `{}`."""
1816 if not path .exists ():
1917 return {}
20- raw = cast (dict [str , JSONDict ], json .loads (path .read_text (encoding = "utf-8" )))
18+ raw = cast (dict [str , Any ], json .loads (path .read_text (encoding = "utf-8" )))
2119 if parse is None :
2220 return cast (dict [str , Entry ], raw )
2321 return {key : parse (value ) for key , value in raw .items ()}
@@ -32,7 +30,7 @@ def save_json_cache(path: Path, cache: Mapping[str, object]) -> None:
3230def load_json_subset [Entry ](
3331 path : Path ,
3432 keys : list [str ],
35- parse : Callable [[JSONDict ], Entry ] | None = None ,
33+ parse : Callable [[Any ], Entry ] | None = None ,
3634) -> dict [str , Entry ]:
3735 """Load only `keys` that are present in a string-keyed JSON cache."""
3836 cache = load_json_cache (path , parse = parse )
0 commit comments