class documentation

class TypeMachineBuilder(Generic[InputProtocol, Core]): (source)

View In Hierarchy

The main entry-point into Automat, used to construct a factory for instances of InputProtocol that take an instance of Core.

Describe the machine with TypeMachineBuilder.state .upon .to, then build it with TypeMachineBuilder.build, like so:

    from typing import Protocol
    class Inputs(Protocol):
        def method(self) -> None: ...
    class Core: ...

    from automat import TypeMachineBuilder
    builder = TypeMachineBuilder(Inputs, Core)
    state = builder.state("state")
    state.upon(Inputs.method).loop().returns(None)
    Machine = builder.build()

    machine = Machine(Core())
    machine.method()
Method build Create a TypeMachine, and prevent further modification to the state machine being built.
Method state Construct a state.
Class Variable coreType Undocumented
Class Variable inputProtocol Undocumented
Method _checkMembership Ensure that ``input`` is a valid member function of the input protocol, not just a function that happens to take the right first argument.
Class Variable _automaton Undocumented
Class Variable _registrars Undocumented
Instance Variable _built Undocumented
Instance Variable _initial Undocumented
def build(self) -> TypeMachine[InputProtocol, Core]: (source)

Create a TypeMachine, and prevent further modification to the state machine being built.

@overload
def state(self, name: str) -> TypedState[InputProtocol, Core]:
@overload
def state(self, name: str, dataFactory: Callable[Concatenate[InputProtocol, Core, P], Data]) -> TypedDataState[InputProtocol, Core, Data, P]:
(source)

Construct a state.

coreType: type[Core] = (source)

Undocumented

inputProtocol: ProtocolAtRuntime[InputProtocol] = (source)

Undocumented

def _checkMembership(self, input: Callable[..., object]): (source)

Ensure that ``input`` is a valid member function of the input protocol, not just a function that happens to take the right first argument.

_automaton: Automaton[TypedState[InputProtocol, Core] | TypedDataState[InputProtocol, Core, Any, ...], str, SomeOutput] = (source)

Undocumented

_registrars: list[TransitionRegistrar[..., ..., Any]] = (source)

Undocumented

_built: bool = (source)

Undocumented

_initial: bool = (source)

Undocumented