flowno.core.mono_node
Type definitions for mono nodes in Flowno’s typechecking system.
A Mono Node is a node that returns a single value or tuple via return statement rather than streaming values via yield. This module defines Protocol classes that improve typechecking specificity for different node arities.
Examples
>>> @node
... def Add(a: int, b: int) -> int:
... return a + b
>>> @node(multiple_outputs=True)
... def SumAndDiff(a: int, b: int):
... return a + b, a - b
Warning
These classes are never instantiated directly - they exist solely for static type checking.
Naming Conventions
MonoNode: Base protocol for all mono nodes regardless of arity
MonoNodeX: Node with X inputs and any number of outputs
MonoNodeX_Y: Node with X inputs and Y outputs
See also
flowno.core.streaming_node
: Type definitions for streaming nodes
- class flowno.core.mono_node.MonoDraftOutputPortRef(node: DraftNode[Unpack, tuple[object, ...]], port_index: OutputPortIndex)[source]
Bases:
DraftOutputPortRef
[_Tout
]
- class flowno.core.mono_node.MonoNode(*args: Unpack)[source]
Bases:
Protocol
[Unpack
[Ts
],_ReturnTupleT_co
]Protocol for mono nodes that produce a single tuple return value.
A mono node is a node that returns a single value or tuple rather than streaming values via yield statements. This class serves as the base Protocol for all mono node arities.
Note: This class is never instantiated - it exists solely for typechecking.
- class flowno.core.mono_node.MonoNode0[source]
Bases:
DraftNode
[_ReturnTupleT_co
]A mono node with 0 inputs that returns a tuple.
See MonoNode for details on the mono node protocol.
- class flowno.core.mono_node.MonoNode0_0[source]
-
A mono node with 0 inputs and 0 outputs.
See MonoNode for details on the mono node protocol.
- class flowno.core.mono_node.MonoNode0_1[source]
Bases:
MonoNode0
[tuple
[_T1_co
]]A mono node with 0 inputs and 1 output.
See MonoNode for details on the mono node protocol.
- output(output_port: Literal[0]) MonoDraftOutputPortRef[_T1_co]
- output(output_port: int) NotImplementedType
Helper for @overload to raise when called.
- class flowno.core.mono_node.MonoNode1(*args: Any)[source]
Bases:
DraftNode
[_T1_contra
,_ReturnTupleT_co
]A mono node with 1 input that returns a tuple.
See MonoNode for details on the mono node protocol.
- class flowno.core.mono_node.MonoNode2[source]
Bases:
DraftNode
[_T1_contra
,_T2_contra
,_ReturnTupleT_co
]A mono node with 2 inputs that returns a tuple.
See MonoNode for details on the mono node protocol.
- flowno.core.mono_node.Ts = Ts
Type variable for the input types of a mono node.