(path: pathlib.Path)
| 23 | |
| 24 | |
| 25 | def load_yaml(path: pathlib.Path) -> Dict[str, Any]: |
| 26 | try: |
| 27 | with path.open("r", encoding="utf-8") as f: |
| 28 | data = yaml.safe_load(f) |
| 29 | except Exception as e: |
| 30 | raise RuntimeError(f"Failed to parse YAML: {path}: {e}") |
| 31 | if data is None: |
| 32 | return {} |
| 33 | if not isinstance(data, dict): |
| 34 | raise RuntimeError(f"Expected mapping at top-level in {path}, got {type(data)}") |
| 35 | return data |
| 36 | |
| 37 | |
| 38 | def main() -> int: |