validation
validation
#
Construction-time validation of a node's inputs, substeps, and settings.
Called once from Procedure.__post_init__ so an ill-typed DAG fails where it
is built, with a message that names the field. The checks mirror the field
roles ([.fields][]):
- inputs must be procedures whose return type structurally matches the
field's
Input[T]—Array[Image]andImageSequenceinterchange; anInput[Path]accepts anyPath(the precise target is checked by the navigation node itself); a bare/TypeVar input accepts anyCGType. - substeps must each be a
Procedure. - settings must match their
Setting[T]at runtime (a backstop under the static check), handling unions,list[...], andtype[...].
[check_type][] is that same "does this type fit that slot" question as a
one-line assertion, so a node's own _resolve_type raises in the same voice
as the field validator here.
check_type(actual, expected, context)
#
Raise unless a value of type actual fits a slot expecting expected.
The one home for "does this type fit that slot", so every node's own
_resolve_type reports a mismatch the same way the field validator does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actual
|
object
|
The |
required |
expected
|
object
|
The |
required |
context
|
str
|
What is being checked, named for the message — e.g.
|
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in capturegraph-lib/capturegraph/procedures/procedure/type_checking/validation.py
fits(actual, expected)
#
Whether a value returning actual fits a slot expecting expected.
Compatibility is structural; a bare CGType/TypeVar bound accepts anything,
and an Input[Path] accepts any Path.
Source code in capturegraph-lib/capturegraph/procedures/procedure/type_checking/validation.py
type_name(cgtype)
#
A CGType's name for an error message (str() for anything else).
validate(node)
#
Type-check every field of node against its annotation; raise on mismatch.