Describe the bug
According to the attrs API reference, attribute names are stripped of leading underscores in the __init__(): different behavior to dataclasses. But this quirk isn't handled by OmegaConf when instantiating the class.
To Reproduce
import attr
from omegaconf import OmegaConf, SCMode
@attr.s
class Foo():
_bar: int = attr.ib(default=0)
OmegaConf.to_container(OmegaConf.structured(Foo), structured_config_mode=SCMode.INSTANTIATE)
Result
omegaconf.errors.ConfigTypeError: Could not create instance of `Foo`: Foo.__init__() got an unexpected keyword argument '_bar'
full_key:
object_type=Foo
Expected result
Foo(_bar=0)
Workaround
Set an alias in attr.ib(...) to the actual attribute name.
Describe the bug According to the attrs API reference, attribute names are stripped of leading underscores in the
__init__()
: different behavior to dataclasses. But this quirk isn't handled by OmegaConf when instantiating the class.To Reproduce
Result
Expected result
Workaround Set an alias in
attr.ib(...)
to the actual attribute name.Additional context