Skip to content

Context & Formatting

Resolve a dotted path against a mapping/object.

Examples:

>>> get_dotted({"a": {"b": 1}}, "a.b")
1
>>> class X: pass
>>> x = X(); x.v = 3
>>> get_dotted({"x": x}, "x.v")
3

Compile a reference spec into a resolver callable.

  • Literals return as-is.
  • "key" fetches from context.
  • "key.inner.attr" traverses mappings/attributes.
  • In strict mode, unresolved references raise LookupError.

Returns:

Type Description
Callable[[Mapping[str, Any]], Any]

A function (ctx) -> value used at runtime to fetch the argument value.

Vectorized compile_ref for kwargs specs.


Precompile a logging template with {dotted.refs}.

Supported tokens
  • {key.path}: read from context
  • {result.path}: read from current step result
  • {key.__len__}: length of the resolved value
  • zero-arg callables (e.g. {plan.model_dump})
  • dict/list are JSON-serialized

Returns:

Type Description
Callable[[Mapping[str, Any], Any], str] | None

A renderer (ctx, result) -> str, or None if fmt is falsy.

Compatibility wrapper that calls the compiled renderer.