First of all, I know that this is not the situation to open this issue, but I came across a situation where I wanted to provide a custom NODE_CLASS to the GenSON Schema parser. Let's simplify:
class ExampleNode(SchemaNode):
def add_object(self, obj):
super().add_object(obj)
print("Hello world")
class ExampleSchemaBuilder(SchemaBuilder):
NODE_CLASS = ExampleNode
I noticed that the print wasn't called at all. Digging deeper, the reason for it is that the meta-class directly references the class SchemaNode, while it should instead use cls.NODE_CLASS.
|
cls.NODE_CLASS = type('%sSchemaNode' % name, (SchemaNode,), |
|
{'STRATEGIES': cls.STRATEGIES}) |
Replacing it by cls.NODE_CLASS instead of SchemaNode for the base class solves the issue.
I'm willing to contribute the change if you think this is a relevant issue.
Have a great day!
First of all, I know that this is not the situation to open this issue, but I came across a situation where I wanted to provide a custom NODE_CLASS to the GenSON Schema parser. Let's simplify:
I noticed that the print wasn't called at all. Digging deeper, the reason for it is that the meta-class directly references the class SchemaNode, while it should instead use cls.NODE_CLASS.
GenSON/genson/schema/builder.py
Lines 25 to 26 in 723f06e
Replacing it by cls.NODE_CLASS instead of SchemaNode for the base class solves the issue.
I'm willing to contribute the change if you think this is a relevant issue.
Have a great day!