Skip to content

Conversation

RichardHoekstra
Copy link

In my own project I am extensively subclassing both 'treelib.Tree' and 'treelib.Node'. Using the 'data' variable, as mentioned in the documentation under advanced usage, does not work well for my use case.

It would make my life easier, and my code prettier, if I can pass additional arguments to Tree.create_node. The dependency injection is already there (self.node_class) and this PR should unlock more of the potential.

treelib/treelib/tree.py

Lines 339 to 346 in 017e891

def create_node(self, tag=None, identifier=None, parent=None, data=None):
"""
Create a child node for given @parent node. If ``identifier`` is absent,
a UUID will be generated automatically.
"""
node = self.node_class(tag=tag, identifier=identifier, data=data)
self.add_node(node, parent)
return node

… you are subclassing treelib.Node extensively and do not want to make use of the 'data' property of treelib.Node.

- Added a test case for the above mentioned 'kwargs'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant