👷 Handle bool values in a better way for settings via cli. Fixes #111

This commit is contained in:
Robert Honz
2024-05-22 22:05:31 +02:00
parent bf5c533aff
commit c27f2c1c0f
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -34,9 +34,11 @@ class BaseConfig:
f.write(data_json)
def set_option(self, key: str, value: Any) -> None:
tmp_data: Any = getattr(self.data, key)
value_old: Any = getattr(self.data, key)
if isinstance(tmp_data, int) and not isinstance(value, int):
if type(value_old) == bool: # noqa: E721
value = True if value.lower() in ("true", "1", "yes", "y") else False # noqa: SIM210
elif type(value_old) == int and type(value) != int: # noqa: E721
value = int(value)
setattr(self.data, key, value)