audeering / audobject

Generic Python interface for serializing objects to YAML
https://audeering.github.io/audobject/
Other
1 stars 0 forks source link

BUG: Cannot inherit borrow, hide and resolvers #12

Closed frankenjoe closed 3 years ago

frankenjoe commented 3 years ago

When deriving from a class that already sets borrow, hide or resolvers, we lose this information in the child class.

Here's an example for borrow:

class Parent(audobject.Object):
    @audobject.init_decorator(
        hide=[            
            'parent',
        ],
    )
    def __init__(
            self,
            parent: bool = False,
    ):
        self.parent = parent

class Child(Parent):
    @audobject.init_decorator(
        hide=[
            'child',            
        ],
    )
    def __init__(
            self,
            child: bool = False,
            parent: bool = False,
    ):        
        super().__init__(parent=parent)
        self.child = child

c = Child()
print(c.to_yaml_s())
$__main__.Child==1.0.0:
  child: false

We can see that child is not hidden as we would expect.