"""Configuration loading.""" from __future__ import annotations import os from pathlib import Path from typing import Any import yaml def _read_yaml(path: Path) -> dict[str, Any]: if not path.exists(): return {} with path.open("r", encoding="utf-8") as handle: return yaml.safe_load(handle) or {} def load_config(config_name: str = "base.yaml") -> dict[str, Any]: root = Path(__file__).resolve().parents[2] config_path = root / "configs" / config_name return _read_yaml(config_path) def env_bool(name: str, default: bool = False) -> bool: raw = os.getenv(name) if raw is None: return default return raw.strip().lower() in {"1", "true", "yes", "on"} def env_int(name: str, default: int) -> int: raw = os.getenv(name) if raw is None: return default try: return int(raw) except ValueError: return default