WIP: feature/cleanup_programming_interface #40

Draft
Hazel wants to merge 35 commits from feature/cleanup_programming_interface into experimental
Showing only changes of commit 850c68f3e5 - Show all commits

View File

@ -28,6 +28,8 @@ class Option:
self._raw_keys = set(keys or [])
self._raw_keys.add(self.text)
self._raw_keys.add(self.value)
self._raw_keys.add(str(self.value))
self.keys = set(self.parse_key(key) for key in self._raw_keys)
def register_key(self, key: Any):
@ -100,10 +102,10 @@ class Select:
yield option
def __contains__(self, key: Any) -> bool:
return key in self._key_to_option
return self._parse_option_key(key) in self._key_to_option
def __getitem__(self, key: Any) -> Option:
return self._key_to_option[key]
return self._key_to_option[self._parse_option_key(key)]
def create_option(self, key: Any, **kwargs) -> Option:
if not self.can_create_options: