You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very specifically, this explicitly preserves declaration order for redefined fields:
frommarrow.schemaimportContainer, AttributeclassFoo(Container):
handler=Attribute()
path=Attribute()
classBar(Foo):
handler=Attribute()
print(Bar.__attributes__)
# handler, path - order preserved despite the redefinition getting a later sequence ID
This metaclass example may provide an approach to resolve this issue.
The text was updated successfully, but these errors were encountered:
There's a use case where subclassing is used for specialization and overriding of default values.
Take this example:
However, there is a bit of an issue that crops up when you have defined multiple fields, then override one this way.
My own declarative schema system uses this chunk of metaclass to avoid this issue: https://github.com/marrow/schema/blob/develop/marrow/schema/meta.py#L60-L95 (apologies for the metaclass bit being exceptionally difficult to grok Python code… nature of the beast.)
Very specifically, this explicitly preserves declaration order for redefined fields:
This metaclass example may provide an approach to resolve this issue.
The text was updated successfully, but these errors were encountered: