Load and return the YAML config at *path*. Returns an empty dict when the file is empty or missing.
(path: Path)
| 42 | |
| 43 | |
| 44 | def load_config(path: Path) -> dict[str, Any]: |
| 45 | """Load and return the YAML config at *path*. |
| 46 | |
| 47 | Returns an empty dict when the file is empty or missing. |
| 48 | """ |
| 49 | if not path.exists(): |
| 50 | return {} |
| 51 | text = path.read_text() |
| 52 | if not text.strip(): |
| 53 | return {} |
| 54 | try: |
| 55 | data = yaml.safe_load(text) |
| 56 | except yaml.YAMLError: |
| 57 | return {} |
| 58 | return data if isinstance(data, dict) else {} |
| 59 | |
| 60 | |
| 61 | def save_config(path: Path, data: dict[str, Any]) -> None: |
no outgoing calls