kd.kontext.resolve_from_keyed_obj

kd.kontext.resolve_from_keyed_obj#

kauldron.kontext.resolve_from_keyed_obj(
context: Any,
keyed_obj: Any,
*,
func: Callable[[...], Any] | None = None,
) dict[str, Any][source]

Resolve the Key annotations of an object for given context.

Parameters:
  • context – Any object from which the values are retrieved.

  • keyed_obj – An instance of a class with fields annotated as Key, or implementing the __kontext_keys__() protocol.

  • func – Optionally pass a function from which the signature should match the keys. This adds some extra checking to ensure the call function signature matches the provided keys.

Returns:

A dict mapping Key names to values from context corresponding to the paths determined by the Key fields.

Raises:

KeyError – If any non-optional keys are mapped to None.