Skip to content

define.param.param_instance

ParamInstanceInteriorNode dataclass

Bases: t.Generic[T]

Tree data stucture that represents all the param values for a particular command execution

Source code in /home/runner/work/arc/arc/arc/define/param/param_instance.py
@dataclass
class ParamInstanceInteriorNode(t.Generic[T]):
    """Tree data stucture that represents all
    the param values for a particular command execution"""

    name: str
    cls: T
    children: list[ParamInstanceInteriorNode[t.Any] | ParamInstanceLeafNode]

    def leaves(self) -> t.Generator[ParamInstanceLeafNode, None, None]:
        for value in self.children:
            if isinstance(value, ParamInstanceInteriorNode):
                yield from value.leaves()
            else:
                yield value

    def compile(self, include_hidden: bool = False) -> T:
        compiled = {}

        for child in self.children:
            if isinstance(child, ParamInstanceInteriorNode):
                compiled[child.name] = child.compile(include_hidden)
            else:
                if child.param.expose or include_hidden:
                    compiled[child.name] = child.value

        return self.cls(**compiled)