Skip to content

BaseNode.children is set as list, but get as tuple #66

@lverweijen

Description

@lverweijen

It seems the children are set as a list, but are returned as a tuple.
I think it would make more sense to set/get it as the same type, probably a tuple.

It makes the following (no-op looking) code illegal:

node = Node("node")
node.children = node.children
# => TypeError: Children input should be list type, received input type <class 'tuple'>

It's risky too, because of the following:

root = Node("root")
mutable_children = list(map(Node, "abc"))

root.children = mutable_children
c = mutable_children.pop()

print(root.children)  # => (Node(/root/a, ), Node(/root/b, ))
print(c.parent)  # => Node(/root, )
raise ZeroDivisionError

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions