class Base(audobject.Object):
@audobject.init_decorator(
resolvers={
't': audobject.resolver.Tuple,
}
)
def __init__(
self,
t: typing.Tuple,
):
self.t = t
s = Base(t).to_yaml_s()
obj = audobject.from_yaml_s(s)
type(obj.t)
<class 'tuple'>
but:
class Child(Base):
def __init__(
self,
t: typing.Tuple,
):
super().__init__(t)
s = Child(t).to_yaml_s()
obj = audobject.from_yaml_s(s)
type(obj.t)
<class 'list'>
In the second case, t is not properly decoded to a tuple. This is because we only decode keyword arguments. Hence, it works if we call the constructor of the base class using keyword arguments, but it would be nicer if this was not necessary:
class Child(Base):
def __init__(
self,
t: typing.Tuple,
):
super().__init__(t=t)
s = Child(t).to_yaml_s()
obj = audobject.from_yaml_s(s)
type(obj.t)
but:
In the second case,
t
is not properly decoded to a tuple. This is because we only decode keyword arguments. Hence, it works if we call the constructor of the base class using keyword arguments, but it would be nicer if this was not necessary: