okld / streamlit-elements

Create a draggable and resizable dashboard in Streamlit, featuring Material UI widgets, Monaco editor (Visual Studio Code), Nivo charts, and more!
MIT License
734 stars 82 forks source link

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

Open sindrelothe opened 2 years ago

sindrelothe commented 2 years ago

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 commented 2 years ago

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

sindrelothe commented 2 years ago

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