coma.hooks.init_hook

Init hook default factory.

default_factory(policy: OverridePolicy = OverridePolicy.RAISE, instance_key: str | None = None) Callable[[T], T | None][source]

Factory for creating an invocation hook with init_hook semantics.

Essentially, creates and returns a hook function as a lightweight wrapper around call_on() called on the current value of the command object with the given policy and instance_key.

Parameters:
  • policy (OverridePolicy) – Policy for dealing with any command-line argument whose name clashes with command parameters.

  • instance_key (InstanceKey, optional) – Which Config instance to use (across all given Config s), or get_latest() if None.

Returns:

A hook with init_hook semantics.

Return type:

Hook