Skip to content

fix: forward extra kwargs from create_node to node_class - #249

Open
Sanjays2402 wants to merge 1 commit into
caesar0301:masterfrom
Sanjays2402:fix/create-node-kwargs
Open

fix: forward extra kwargs from create_node to node_class#249
Sanjays2402 wants to merge 1 commit into
caesar0301:masterfrom
Sanjays2402:fix/create-node-kwargs

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #240

The Custom Node Classes docs example fails with TypeError: create_node() got an unexpected keyword argument 'size': Tree.create_node() only forwards tag/identifier/data to self.node_class, so a Node subclass with extra constructor arguments is unusable through the documented API. Extra keyword arguments are now forwarded to the node class, and the docs example takes/forwards **kwargs so the Node base still receives data/expanded.

Regression test added beside test_subclassing in tests/test_tree.py; it fails with TypeError without the change and passes with it (full tests/test_tree.py: 74 passed).

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

Tree.create_node() only passed tag/identifier/data to the tree's
node_class, so the custom-Node example in the docs raised
TypeError: create_node() got an unexpected keyword argument 'size'.
Extra keyword arguments are now forwarded to the node_class
constructor, and the docs example accepts/forwards **kwargs so the
Node base still receives data/expanded.

Fixes caesar0301#240
@Sanjays2402
Sanjays2402 requested a review from liamlundy as a code owner July 31, 2026 17:46
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.

the example for "custom node class" doesn´t work, additional parameters are not recognized

1 participant