Load the project configuration from disk. Args: project_dir: Path to the project directory. Returns: Configuration dictionary, or empty dict if file doesn't exist or is invalid.
(project_dir: Path)
| 107 | |
| 108 | |
| 109 | def _load_config(project_dir: Path) -> dict: |
| 110 | """ |
| 111 | Load the project configuration from disk. |
| 112 | |
| 113 | Args: |
| 114 | project_dir: Path to the project directory. |
| 115 | |
| 116 | Returns: |
| 117 | Configuration dictionary, or empty dict if file doesn't exist or is invalid. |
| 118 | """ |
| 119 | config_path = _get_config_path(project_dir) |
| 120 | |
| 121 | if not config_path.exists(): |
| 122 | return {} |
| 123 | |
| 124 | try: |
| 125 | with open(config_path, "r", encoding="utf-8") as f: |
| 126 | config = json.load(f) |
| 127 | |
| 128 | if not isinstance(config, dict): |
| 129 | logger.warning( |
| 130 | "Invalid config format in %s: expected dict, got %s", |
| 131 | config_path, type(config).__name__ |
| 132 | ) |
| 133 | return {} |
| 134 | |
| 135 | return config |
| 136 | |
| 137 | except json.JSONDecodeError as e: |
| 138 | logger.warning("Failed to parse config at %s: %s", config_path, e) |
| 139 | return {} |
| 140 | except OSError as e: |
| 141 | logger.warning("Failed to read config at %s: %s", config_path, e) |
| 142 | return {} |
| 143 | |
| 144 | |
| 145 | def _save_config(project_dir: Path, config: dict) -> None: |
no test coverage detected