INNER CODE UNIT · Python

_read_json

MinaProtocol/mina · maintenance/deps/main.py:93

def _read_json(path: Path) -> Any | None:
    if not path.exists():
        return None
    try:
        return json.loads(path.read_text(encoding="utf-8"))
    except json.JSONDecodeError as error:
        raise DepsError(
            ErrorCode.MALFORMED_JSON, f"{path} is not valid JSON: {error}", path=path
        ) from error


def parse_baseline(raw: Any) -> Baseline:
    entrypoints = {
        NodeId(node_id): Budget(libs=int(value["libs"]), opam=int(value["opam"]))
        for node_id, value in raw.get("entrypoints", {}).items()
    }
    unreferenced = {
        (NodeId(pair[0]), NodeId(pair[1])) for pair in raw.get("unreferenced", []) if len(pair) == 2

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…