Closed Zacharias030 closed 9 months ago
Maybe changing the omegaconf.errors.ConfigAttributeError
to inherit from python's built in AttributeError
would solve this.
@Zacharias030, can you confirm this?
It's already extending AttribuiteError.
class ConfigAttributeError(OmegaConfBaseException, AttributeError):
Please provide a minimum runnable repro. This runs success fly for me:
from omegaconf import OmegaConf
cfg = OmegaConf.create()
if getattr(cfg , "aaa", None) is None:
print("Missing field aaa")
OmegaConf.set_struct(cfg, True)
if getattr(cfg , "aaa", None) is None:
print("Missing field aaa")
And outputs
Missing field aaa
Missing field aaa
Describe the bug
does not return
None
ifconfig: DictConfig
doesn't have the attribute, because it raises anomegaconf.errors.ConfigAttributeError
.To Reproduce Please provide a minimal repro. This can include a small Python file, and potentially a few small config files. If you have more than one file you can attach a zip file with everything to the issue.
Expected behavior I understand that custom errors are useful sometimes, but I expect that attributes behave like attributes and that
getattr(...)
returns without raising.