"""Load the optional .spens.config.json from the workspace directory."""

from __future__ import annotations

import json
from pathlib import Path
from typing import Any

CONFIG_FILENAME = ".spens.config.json"


def load_config(workspace: str | Path) -> dict[str, Any] | None:
    path = Path(workspace).resolve() / CONFIG_FILENAME
    if not path.exists():
        return None
    with open(path, encoding="utf-8") as fh:
        return json.load(fh)
