diff --git a/jac/jaclang/runtimelib/machine.py b/jac/jaclang/runtimelib/machine.py index 52ca0cd7e..cb45b6476 100644 --- a/jac/jaclang/runtimelib/machine.py +++ b/jac/jaclang/runtimelib/machine.py @@ -151,19 +151,23 @@ def update_walker( logger.warning(f"Module {module_name} not found in loaded modules.") return () - def spawn_node(self, node_name: str, attributes: dict = {}, module_name: str = '__main__') -> NodeArchitype: + def spawn_node(self, node_name: str, attributes: dict = None, module_name: str = '__main__') -> NodeArchitype: """Spawn a node instance of the given node_name with attributes.""" node_class = self.get_architype(module_name, node_name) if isinstance(node_class, type) and issubclass(node_class, NodeArchitype): + if attributes is None: + attributes = {} node_instance = node_class(**attributes) return node_instance else: raise ValueError(f"Node {node_name} not found.") - def spawn_walker(self, walker_name: str, attributes: dict = {}, module_name: str = '__main__') -> WalkerArchitype: + def spawn_walker(self, walker_name: str, attributes: dict = None, module_name: str = '__main__') -> WalkerArchitype: """Spawn a walker instance of the given walker_name.""" walker_class = self.get_architype(module_name, walker_name) if isinstance(walker_class, type) and issubclass(walker_class, WalkerArchitype): + if attributes is None: + attributes = {} walker_instance = walker_class(**attributes) return walker_instance else: