I have the following code for a tree structure:
class Node:
def __init__(self, node_id: str):
self.node_id = node_id
self.children = []
I found about marshmallow-oneofschema
Although not integrated to the core, I think marshmallow-oneofschema is the recommended way to do polymorphism.
this leads to a circular import
You may pass the name as string to solve the circular import issue.
children = fields.Nested('SomeNodeSchema', many=True)