spekk.trees.registry.register_dispatch_fn

spekk.trees.registry.register_dispatch_fn#

spekk.trees.registry.register_dispatch_fn(dispatch_fn: Callable[[Mapping[Any, Mapping[Any, Tree] | Sequence[Tree] | Any] | Sequence[Mapping[Any, Tree] | Sequence[Tree] | Any] | Any], TreeDef | None])[source]#

Register a new TreeDef by dispatch function.

Multiple dispatch functions may be registered, in which case they will be tried in order until one of them returns a TreeDef. Note that dispatch_by_type() and dispatch_treedef() always comes first and takes precendence.