Describe the bug
When creating and extending a structured config with an attribute opt: Optional[T] = None (where T is a container type), it is not possible to set any keys in opt using OmegaConf.update(), as trying to do so raises the error "Unexpected type for root" here (OmegaConf expects an existing Container, but receives None, our default value).
To Reproduce
from dataclasses import dataclass
from omegaconf import OmegaConf
from typing import Optional
@dataclass
class SubConfig:
val: int = 0
@dataclass
class Config:
opt: Optional[SubConfig] = None
if __name__ == "__main__":
conf = OmegaConf.structured(Config)
OmegaConf.update(conf, "opt.val", 42, merge=True)
Expected behavior
The structured config attribute opt should be initialized as a container, followed by the requested update.
Describe the bug When creating and extending a structured config with an attribute
opt: Optional[T] = None
(whereT
is a container type), it is not possible to set any keys inopt
usingOmegaConf.update()
, as trying to do so raises the error "Unexpected type for root" here (OmegaConf expects an existingContainer
, but receivesNone
, our default value).To Reproduce
Expected behavior The structured config attribute
opt
should be initialized as a container, followed by the requested update.Additional context