Closed tomtwttr closed 4 years ago
python itself doesn't support recursive types, so even to express this you will need to create a function called something like Indirect
, then do
class Tree(Struct):
value = Integer
node_left = Indirect('Tree')
node_right = Indirect('Tree')
The Indirect
function would then create something that could be interpreted by the metaclass to hand to the type system that redirects the type checker back to the Tree type.