Skip to content

initialization

initialization #

Construction and subclassing hooks bound onto Procedure.

__post_init__ runs after every node's dataclass __init__: it stamps identity, validates the node, and registers it with the active recording context. __init_subclass__ records each subclass's declared return type.

__init_subclass__(cls) #

Record the subclass's return type from its Procedure[X] base.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/initialization.py
def __init_subclass__(cls: type[Procedure]) -> None:
    """Record the subclass's return type from its ``Procedure[X]`` base."""
    from capturegraph.procedures.procedure import (
        Procedure,
    )

    super(Procedure, cls).__init_subclass__()
    declared = declared_return_type(cls)
    if declared is not None:
        cls._return_type = declared

__post_init__(self) #

Stamp identity, type-check the node, and register it with the context.

Constructing a node registers it with the active recording context (which is how a procedure body is built — see capturegraph.procedures.procedure.authoring.contexts). There must be one: a node built with no active context raises, unless under cg.detached().

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/initialization.py
def __post_init__(self: Procedure) -> None:
    """Stamp identity, type-check the node, and register it with the context.

    Constructing a node registers it with the active recording context (which
    is how a procedure body is built — see
    [capturegraph.procedures.procedure.authoring.contexts][]). There must be one: a node
    built with no active context raises, unless under ``cg.detached()``.
    """
    object.__setattr__(self, "_uuid", _new_uuid())
    object.__setattr__(self, "_children", {})
    validation.validate(self)
    from capturegraph.procedures.procedure.authoring.contexts.base import (
        ProcedureContext,
    )

    ProcedureContext.current()._collect(self)