-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
Voight Kampff Integration Test Failed (Results). |
Voight Kampff Integration Test Succeeded (Results) |
Looks good. For some history, this was originally left out to make the class as different as possible to the standard dict since we didn't wish to implement it fully. For example it has no I would encourage to also add at least edit: |
mycroft/enclosure/gui.py
Outdated
@@ -110,6 +110,14 @@ def __getitem__(self, key): | |||
"""Implements get part of dict-like behaviour with named keys.""" | |||
return self.__session_data[key] | |||
|
|||
def get(self, key, value=None): | |||
"""Implements the get method for accessing dict keys.""" | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Instead of this implementation just forward to __session_data.get
def get(self, *args, **kwargs):
return self.__session_data.get(*args, **kwargs)
8a69506
to
cae1cb7
Compare
I changed to your suggested implementation and thought of adding So I thought it worth deciding what we really want here and whether it would be easier to inherit from dict rather than re-adding everything or if that will introduce it's own strange behaviour. |
Voight Kampff Integration Test Failed (Results). |
Indeed, this was what we thought when we created it. Limit it to the basics and then if needed make it a subclass of dict. |
Voight Kampff Integration Test Succeeded (Results) |
Description
Currently if a Skill attempts to access a value on the GUI interface that doesn't exist a KeyError will be raised.
This implements the Pythonic behaviour of a dict.get() method to provide a safer mechanism for accessing those keys including an optional parameter for returning a default value.
While there, I added some extra unittests for the
SkillGUI
class.How to test
Unit tests included. Or you can drop the following into a Skills
initialize
methodContributor license agreement signed?