Open raphCode opened 1 year ago
Thanks, @raphCode. I agree that this looks like a bug. A few notes:
dataclasses
; this is not an attrs
-specific bug.dict
instead of list
in the type hint:
from omegaconf import OmegaConf
from attrs import frozen
@frozen class A: num: int
@frozen class C: a: A aa: dict[int, A]
c = OmegaConf.structured(C) c = OmegaConf.merge(dict(a=dict(num=1), aa={0: dict(num=2)}), c) assert OmegaConf.get_type(c.a) == A assert OmegaConf.get_type(c.aa[0]) == A # fails
Describe the bug
OmegaConf.merge(config, structured)
fails to merge dataclasses contained in a list. This means type information are not present in the resultant config. Related: https://github.com/facebookresearch/hydra/discussions/2586To Reproduce
Expected behavior All asserts pass. Note that reversing the merge order to
merge(c, dict(...))
correctly propagates the types into the list.Additional context