(path: Path)
| 80 | |
| 81 | |
| 82 | def load_json(path: Path) -> JSONDict: |
| 83 | with path.open(encoding="utf-8") as handle: |
| 84 | raw_data = cast(object, json.load(handle)) |
| 85 | |
| 86 | if not isinstance(raw_data, dict): |
| 87 | raise ValueError(f"Expected JSON object in {path}") |
| 88 | |
| 89 | raw_keys = cast(Iterable[object], raw_data.keys()) |
| 90 | if not all(isinstance(key, str) for key in raw_keys): |
| 91 | raise ValueError(f"Expected JSON object with string keys in {path}") |
| 92 | |
| 93 | return cast(JSONDict, raw_data) |
| 94 | |
| 95 | |
| 96 | def write_sorted_json(path: Path, payload: Mapping[str, object]) -> None: |
no test coverage detected