feat: implemented functionality to type out the choice
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Hazel 2024-05-27 14:00:01 +02:00
parent 7219048422
commit 850c68f3e5

View File

@ -28,6 +28,8 @@ class Option:
self._raw_keys = set(keys or []) self._raw_keys = set(keys or [])
self._raw_keys.add(self.text) 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) self.keys = set(self.parse_key(key) for key in self._raw_keys)
def register_key(self, key: Any): def register_key(self, key: Any):
@ -100,10 +102,10 @@ class Select:
yield option yield option
def __contains__(self, key: Any) -> bool: 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: 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: def create_option(self, key: Any, **kwargs) -> Option:
if not self.can_create_options: if not self.can_create_options: