Skip to main content

NodeRegistryEntry

One registered node type and the functions that open and close it.

Attributes: type: The registered class. flatten_fn: flatten_fn(node) -> (children, context) or (children, context, entries). children is any iterable; context is whatever the type needs to rebuild itself (kept in the treespec, compared with == and hashed when hashable); entries names each child for key paths (range(len(children)) when omitted or None). unflatten_fn: unflatten_fn(children, context) -> node, with children a tuple in flatten order. The registry holds this one calling convention; the __tree_unflatten__(cls, context, children) method form is adapted to it at registration. kind: The :class:TreeKind of nodes of this type. namespace: The namespace the entry was registered under ("" is the global namespace). serialized_type_name: The name a serialized treespec uses for this type. to_dumpable_context: Turns a context into a JSON-serializable value. from_dumpable_context: The inverse of to_dumpable_context. flatten_with_keys_fn: flatten_with_keys_fn(node) -> ([(key, child), ...], context), the key-path form of flatten_fn.

__init__​

__init__(self, type: 'type', flatten_fn: 'FlattenFn', unflatten_fn: 'UnflattenFn', kind: 'TreeKind' = <TreeKind.CUSTOM: 0>, namespace: 'str' = '', serialized_type_name: 'str | None' = None, to_dumpable_context: 'ToDumpableContextFn | None' = None, from_dumpable_context: 'FromDumpableContextFn | None' = None, flatten_with_keys_fn: 'FlattenWithKeysFn | None' = None) -> None

Initialize self. See help(type(self)) for accurate signature.