MCPcopy Index your code
hub / github.com/google/adk-python / _normalize

Function _normalize

tests/unittests/telemetry/functional_test_helpers.py:256–272  ·  view source on GitHub ↗

Normalizes a value for stable equality. * Tuples become lists (OTel coerces sequences to tuples on attributes). * Enums become their ``.value``. * Dict entries whose value is ``None`` are dropped (these are inserted by pydantic ``model_dump`` for unset fields and would dominate diffs).

(value: object)

Source from the content-addressed store, hash-verified

254
255
256def _normalize(value: object) -> object:
257 """Normalizes a value for stable equality.
258
259 * Tuples become lists (OTel coerces sequences to tuples on attributes).
260 * Enums become their ``.value``.
261 * Dict entries whose value is ``None`` are dropped (these are inserted by
262 pydantic ``model_dump`` for unset fields and would dominate diffs).
263 """
264 if isinstance(value, Enum):
265 return value.value
266 if isinstance(value, tuple):
267 return [_normalize(v) for v in value]
268 if isinstance(value, list):
269 return [_normalize(v) for v in value]
270 if isinstance(value, dict):
271 return {k: _normalize(v) for k, v in value.items() if v is not None}
272 return value
273
274
275# ---------------------------------------------------------------------------

Callers 2

from_logMethod · 0.85
from_spanMethod · 0.85

Calls 1

itemsMethod · 0.45

Tested by

no test coverage detected