Skip to content

ArrayNode

Base classes

Name Children Inherits
NodeBase
promptantic.form.nodes
Common to all nodes.

⋔ Inheritance diagram

graph TD
  1502139479["nodes.ArrayNode"]
  1324256109["nodes.NodeBase"]
  2751680898["builtins.object"]
  1324256109 --> 1502139479
  2751680898 --> 1324256109

🛈 DocStrings

Bases: NodeBase

A list of items of one kind.

Source code in src/promptantic/form/nodes.py
@dataclass(frozen=True, eq=False)
class ArrayNode(NodeBase):
    """A list of items of one kind."""

    kind: Literal["array"] = "array"
    min_items: int | None = None
    max_items: int | None = None
    unique: bool = False
    build_items: Callable[[], FormNode] | None = field(default=None, repr=False)

    @cached_property
    def items(self) -> FormNode:
        """The node every item follows (built on first access)."""
        if self.build_items is None:
            return AnyNode(meta=Meta())
        return self.build_items()

    @property
    def multi_choice(self) -> bool:
        """Items are choices and unique: a pick-several list rather than an item editor."""
        return isinstance(self.items, ChoiceNode) and not self.items.fixed

items cached property

items: FormNode

The node every item follows (built on first access).

multi_choice property

multi_choice: bool

Items are choices and unique: a pick-several list rather than an item editor.

:fa-brands-github: Show source on GitHub