streamlit-elements icon indicating copy to clipboard operation
streamlit-elements copied to clipboard

Add AttributeError to __getattr__ in /core/callback.py ElementsCallbackData

Open sindrelothe opened this issue 3 years ago • 2 comments

getattr should raise a AttributeError when value is not found, not KeyError, which is raised when getitem fails. New function should look like

class ElementsCallbackData(dict): slots = ()

def __getattr__(self, value):
    try:
        return self.__getitem__(value)
    except:
        raise AttributeError

sindrelothe avatar Jul 18 '22 08:07 sindrelothe

See here for more: https://docs.python.org/3/reference/datamodel.html?highlight=getattr#object.getattr

sindrelothe avatar Jul 18 '22 08:07 sindrelothe

Made pr for this feature here: https://github.com/okld/streamlit-elements/pull/10

sindrelothe avatar Jul 18 '22 10:07 sindrelothe