prodict icon indicating copy to clipboard operation
prodict copied to clipboard

getattr() should raise AttributeError

Open adm271828 opened this issue 2 months ago • 0 comments

Hi,

I don't know if this is maintained anymore, but I would suggest that getattr() raises an AttributeError instead of KeyError.

This would avoid breaking other libraries that expect getattr() ro raise an AttributeError such as Jinja2 for instance (but not only, also had trouble with omegaconf when creating a DictConfig from Prodict).

Best regards,

Antoine

    def __getattr__(self, item):
        try:
            return self[item]
        except KeyError as exc:
            raise AttributeError(str(exc))

adm271828 avatar May 13 '24 08:05 adm271828