Read a dotted metric path, returning 0 if any segment is missing.
(page: dict[str, Any], key: str)
| 95 | |
| 96 | |
| 97 | def _get_metric(page: dict[str, Any], key: str) -> int | float: |
| 98 | """Read a dotted metric path, returning 0 if any segment is missing.""" |
| 99 | value: Any = page.get("metrics", {}) |
| 100 | for part in key.split("."): |
| 101 | if not isinstance(value, dict) or part not in value: |
| 102 | return 0 |
| 103 | value = value[part] |
| 104 | if not isinstance(value, int | float) or isinstance(value, bool): |
| 105 | return 0 |
| 106 | return value |
| 107 | |
| 108 | |
| 109 | def _format_delta(before: int | float, after: int | float) -> str: |
no outgoing calls
no test coverage detected