nylas/nylas-python

RestfulModel Breaks `hasattr`

jpulec opened this issue · 2 comments

Describe the bug
The RestfulModel class is a subclass of dict, and overrides __getattr__ to call dict.get(). A side effect of this, is that calling hasattr on a RestfulModel class will always return True, for any value. This is because internally hasattr calls getattr(object, 'attrname') and only returns False if an AttributeError is thrown. Since __getattr__ has been overridden to call dict.get() an AttributeError will never be raised.

@jpulec Thanks for opening this issue, we are taking a look and will update you as soon as we have something!

@jpulec Just wanted to update you that we have fixed this issue and currently we are testing for the upcoming v6 major release! I'll close the issue but I'll ping you in this ticket when the new version is release. For more details on the implementation please see #245.