class BaseMixin(BaseModel):
# Note this is pydantic private method that
# is called after __init__
# In order to inject __hera_init__ after __init__
# without destroying the autocomplete, we have opted
# for this method. We also tried other ways
# including creating a metaclass that invokes hera_init
# after init, but that always broke auto-complete for vscode
def _init_private_attributes(self):
super()._init_private_attributes()
self.__hera_init__()
def __hera_init__(self):
...
@root_validator(pre=True)
def _set_defaults(cls, values):
defaults = global_config._get_class_defaults(cls)
for key, value in defaults.items():
if values.get(key) is None:
values[key] = value
return values