Skip to content

Metainfo add detection of mixed inheritance

Theodore Chang requested to merge metainfo-ensure-no-dup-properties into develop

This is to ensure the following construct will work and does not raise errors.

Overwriting Quantity with SubSection in the derived class and vice versa is technically possible but not considered by default. So the current code base assumes Quantity is only overridden by Quantity.

    class A(MSection):
        q = Quantity(type=float)

    class B(A):
        q = SubSection(section=A)

    class C(B):
        q = Quantity(type=str)

    class D(C):
        q = SubSection(section=B)

To allow mixed inheritance, the following needs to be done.

1. Ensure 'inheriting' missing properties from parents will only copy those definitions of the same type. So if Quantity inherits SubSection, no properties shall be passed on. 2. Ensure all_ dictionaries are revised accordingly, the overridden Quantity/SubSection shall be removed from the corresponding container if it is overridden by a different type.

Not supporting this. Raise an error instead.

Edited by Theodore Chang

Merge request reports