You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
graph: parameterize GraphBuilder/CompiledGraph on StateT (PEP 695 generics) (#3)
* graph: parameterize builder/compiled/subgraph on StateT (PEP 695 generics)
Carry the concrete State subclass through at type-check time.
GraphBuilder[StateT], CompiledGraph[StateT], SubgraphNode[ParentT, ChildT],
ConditionalEdge[StateT], ProjectionStrategy[ParentT, ChildT], Node[StateT],
FunctionNode[StateT] — all generic. Consumers no longer need
cast(MyState, ...) on invoke() returns, projection arguments, or edge
function parameters.
PEP 695 syntax throughout (targets Python 3.12+). SubgraphNode carries
both parent and child types; add_subgraph_node[ChildT: State] infers
ChildT from the compiled argument. FieldNameMatching[ParentT, ChildT]
is generic for Protocol conformance even though ParentT is unused in
project_in (keeps default-factory inference clean at the SubgraphNode
boundary).
_merge_partial[StateT] parameterized so type(prior).model_validate
preserves the subclass without an internal cast. Conformance adapter
pins to [State, State, State] since YAML fixtures are schema-agnostic.
Adds tests/unit/test_generics.py with assert_type to lock the typing
surface against regression. 41 tests pass, pyright strict clean.
* gitignore _docs/
0 commit comments