GitHub

Definition

API reference for Definition.

An input schema and the named decisions answered together in one provider call. A stays invariant: decide(definition, input=...) infers A from both, and a covariant A would widen it to accept any input.

Attributes

AttributeTypeDescription
inputS.Codec[A, Any, Any, RE_co]
decisionsMapping[str, AnyDecision]
json_inputS.Bottom[A, JsonValue, Any, RE_co] = field(init=False, repr=False)

input as a JSON codec (S.to_codec_json): the state sent.

Functions

__init__

__init__(input, decisions) -> None
ParameterTypeDescription
inputS.Codec[A, Any, Any, RE_co]
decisionsMapping[str, AnyDecision]

name_of

name_of(decision) -> str

The name decision has here; KeyError when it has none.

ParameterTypeDescription
decisionAnyDecision

Returns str

def name_of(self, decision: AnyDecision) -> str:
    """The name ``decision`` has here; ``KeyError`` when it has none."""
    for name, candidate in self.decisions.items():
        if candidate is decision:
            return name
    raise KeyError(decision)