Return a machine-readable integration status report for *project_root*.
(project_root: Path)
| 350 | |
| 351 | |
| 352 | def build_integration_status_report(project_root: Path) -> dict[str, Any]: |
| 353 | """Return a machine-readable integration status report for *project_root*.""" |
| 354 | findings: list[dict[str, str]] = [] |
| 355 | project_root_resolved, project_root_is_resolved = _resolve_project_root_for_status( |
| 356 | project_root, |
| 357 | findings, |
| 358 | ) |
| 359 | state, raw_state, error = try_read_integration_json_with_raw(project_root) |
| 360 | if error is not None: |
| 361 | findings.append( |
| 362 | _finding( |
| 363 | "error", |
| 364 | "integration-state-unreadable", |
| 365 | _integration_state_error_message(error), |
| 366 | path=INTEGRATION_JSON, |
| 367 | suggestion=f"Fix or delete {INTEGRATION_JSON}, then retry.", |
| 368 | ) |
| 369 | ) |
| 370 | return _build_report(None, [], findings, {}, None) |
| 371 | |
| 372 | if state is None: |
| 373 | findings.append( |
| 374 | _finding( |
| 375 | "error", |
| 376 | "integration-state-missing", |
| 377 | f"{INTEGRATION_JSON} is missing.", |
| 378 | path=INTEGRATION_JSON, |
| 379 | suggestion="Run `specify integration install <key>` to install an integration.", |
| 380 | ) |
| 381 | ) |
| 382 | return _build_report(None, [], findings, {}, None) |
| 383 | |
| 384 | assert raw_state is not None |
| 385 | raw_default_key = default_integration_key(raw_state) |
| 386 | raw_installed_value = raw_state.get("installed_integrations") |
| 387 | raw_installed_is_list = isinstance(raw_installed_value, list) |
| 388 | raw_installed_keys = ( |
| 389 | installed_integration_keys(raw_state) |
| 390 | if raw_installed_is_list |
| 391 | else [] |
| 392 | ) |
| 393 | default_key = raw_default_key or default_integration_key(state) |
| 394 | installed_keys = installed_integration_keys(state) |
| 395 | raw_default_not_installed = _default_not_installed_from_raw_state(raw_state) |
| 396 | if raw_installed_is_list and raw_default_not_installed and raw_installed_keys: |
| 397 | check_installed_keys = raw_installed_keys |
| 398 | else: |
| 399 | check_installed_keys = installed_keys |
| 400 | recorded_installed_keys = raw_installed_keys |
| 401 | if "installed_integrations" in raw_state and not raw_installed_is_list: |
| 402 | findings.append( |
| 403 | _finding( |
| 404 | "warning", |
| 405 | "installed-integrations-invalid", |
| 406 | ( |
| 407 | "installed_integrations must be a list, " |
| 408 | f"got {type(raw_installed_value).__name__}." |
| 409 | ), |
no test coverage detected