class documentation

class TransitionRegistrar(Generic[P, P1, R]): (source)

View In Hierarchy

This is a record of a transition that need finalizing; it is the result of calling TypeMachineBuilder.state and then ``.upon(input).to(state)`` on the result of that.

It can be used as a decorator, like:

    registrar = state.upon(Proto.input).to(state2)
    @registrar
    def inputImplementation(proto: Proto, core: Core) -> Result: ...

Or, it can be used used to implement a constant return value with TransitionRegistrar.returns, like:

    registrar = state.upon(Proto.input).to(state2)
    registrar.returns(value)

Type parameter P: the precise signature of the decorated implementation callable.

Type parameter P1: the precise signature of the input method from the outward-facing state-machine protocol.

Type parameter R: the return type of both the protocol method and the input method.

Method __call__ Finalize it with __call__ to indicate that there is an implementation to the transition, which can be treated as an output.
Method returns Finalize it with .returns(constant) to indicate that there is no method body, and the given result can just be yielded each time after the state transition. The only output generated in this case would be the data-construction factory for the target state.
Method _checkComplete Raise an exception if the user forgot to decorate a method implementation or supply a return value for this transition.
Class Variable _new Undocumented
Class Variable _nodata Undocumented
Class Variable _old Undocumented
Class Variable _signature Undocumented
Instance Variable _callback Undocumented
def __call__(self, impl: Callable[P, R]) -> Callable[P, R]: (source)

Finalize it with __call__ to indicate that there is an implementation to the transition, which can be treated as an output.

def returns(self, result: R): (source)

Finalize it with .returns(constant) to indicate that there is no method body, and the given result can just be yielded each time after the state transition. The only output generated in this case would be the data-construction factory for the target state.

def _checkComplete(self): (source)

Raise an exception if the user forgot to decorate a method implementation or supply a return value for this transition.

Undocumented

_nodata: bool = (source)

Undocumented

Undocumented

_signature: Callable[P1, R] = (source)

Undocumented

_callback: Callable[P, R] | None = (source)

Undocumented