Node policy
If a field is not marked with to.field the following policy will be applied when determining whether a field is a node or not:
- If the field is annotated with a
Treesubtype or a generic containing aTreesubtype e.g.List[to.Tree], the field is considered a node. - If the runtime value of the field is a
to.Treeinstance, the field is considered a node. TheTree's metadata will be updated to reflect this. - If none of the above apply, the field is considered a static field.
import treeo as to
class Agent(to.Tree):
...
class Game(to.Tree):
player: Agent # node
cpus: List[Agent] # node
max_cpus: int # static
def __init__(self, ...):
...
self.boss = Agent(...) # runtime node
Note: the kind of all fields that are not explicitly declarated is set to NoneType.