annotations
annotations
#
Pure functions over field annotations.
The one place get_origin / get_args / optional-union unwrapping lives.
Everything here is a small, total function from an annotation object to a plain
answer; nothing imports the node layer or touches an instance. The classifier
([.fields][]), the validator (.validation), and the construction hook
([.construction][]) all read field annotations through here, so the rules for
"what does Input[Image] | None mean" are written once.
input_value_type(annotation)
#
The T an Input[T] field carries — the return type it accepts.
Unwraps an optional union (Input[Location] | None) to its input member,
then extracts T. A bare Input / Procedure (or one parameterized by
a still-unresolved TypeVar on a generic node) yields CGType — the "any
CGType" bound, checked precisely by the node's own __post_init__.
Source code in capturegraph-lib/capturegraph/procedures/procedure/type_checking/annotations.py
is_input(annotation)
#
Whether annotation is an input field (optionally | None).
is_optional(annotation)
#
Whether annotation is a union that includes None.
is_substeps(annotation)
#
setting_value_type(annotation)
#
The T a Setting[T] field holds, with the wrapper peeled away.
Also peels an optional | None off first. Setting[str] → str;
Setting[int | float] | None → int | float; a plain (already-unwrapped)
annotation is returned as-is.
Source code in capturegraph-lib/capturegraph/procedures/procedure/type_checking/annotations.py
union_members(annotation)
#
The members of a union annotation, or (annotation,) if it is not one.
Input[Image] | None → (Input[Image], NoneType); a non-union is
returned as a one-tuple so callers can iterate uniformly.