MCPcopy Create free account
hub / github.com/idank/explainshell / _get_metric

Function _get_metric

tests/evals/_common.py:97–106  ·  view source on GitHub ↗

Read a dotted metric path, returning 0 if any segment is missing.

(page: dict[str, Any], key: str)

Source from the content-addressed store, hash-verified

95
96
97def _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
109def _format_delta(before: int | float, after: int | float) -> str:

Callers 4

_suspicious_page_changesFunction · 0.90
_suspicious_changesFunction · 0.90
_changed_metric_linesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected