John Reese <jre...@leetcode.net> added the comment:
The problem I'm trying to solve is around functions that operate on a Union[Leaf, Node], and want to be able to do things like `grandchildren = node.children[0].children + node.children[1].children` (contrived example, but point being tuple+list=TypeError while list+tuple=OK). There are similar cases around list methods not being available for tuples. In both cases, as is, the function needs to do some amount of type checking at runtime of each child to determine what operations can be done. Also, IMO, from a type annotation perspective, having a child class that uses a different type for an attribute from the base class is an anti-pattern, or weird at best. re. error prone: Since the expectation in lib2to3 is already that fixers shouldn't be modifying `node.children` directly, I don't see how this makes anything more error prone. Base/Leaf objects lack those methods for modifications, so unless the code is already being a bad actor, the situation isn't changed. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33983> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com