From bb431b83c14673ed9343a59939d8d2ecaa5c4bb7 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 23 Nov 2020 08:01:27 +0200 Subject: [PATCH] Added bool support to MacConfig --- config.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index ba1063a6..d6ab45b3 100644 --- a/config.py +++ b/config.py @@ -582,7 +582,17 @@ class MacConfig(AbstractConfig): logger.error(f'__raw_get returned {res!r} which cannot be parsed to an int: {e}') return default - def set(self, key: str, val: Union[int, str, List[str]]) -> None: + def get_bool(self, key: str, default: Optional[bool] = None) -> Optional[bool]: + res = self.__raw_get(key) + if res is None: + return default + + elif not isinstance(res, bool): + raise ValueError(f'__raw_get returned unexpected type {type(res)=} {res!r}') + + return res + + def set(self, key: str, val: Union[int, str, List[str], bool]) -> None: """ Set sets the given key to the given value.