coma.hooks.init_hook

Init hook utilities, factories, and defaults.

positional_factory(*skips: str) Callable[source]

Factory for creating an init hook that instantiates a command with some configs.

Instantiates the command object by invoking it with all configs given as positional arguments.

Note

This works because the hook protocol assumes the configs dictionary is insertion-ordered.

Parameters

*skips (str) – Undesired configs can be skipped by providing the appropriate config identifiers

Returns

An init hook

keyword_factory(*skips: str, force: bool = False) Callable[source]

Factory for creating an init hook that instantiates a command with some configs.

Instantiates the command object by invoking it with all configs given as keyword arguments based on matching parameter names in the command’s function signature.

Parameters
  • *skips (str) – Undesired configs can be skipped by providing the appropriate config identifiers

  • force (bool) – For all un-skipped configs, whether to forcibly pass them to the command object, even if no parameter names in the command’s function signature match a particular config identifier. In this case, TypeError will be raised unless the command’s function signature includes variadic keyword arguments.

Returns

An init hook

default(command: Callable, configs: Dict[str, Any]) Any

Default init hook.

An alias for calling coma.hooks.init_hook.positional_factory() with default arguments.