From 67453ac8bc640377fe3ed8b0a491c224d85408ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Pich=C3=A9?= Date: Wed, 24 Apr 2024 08:38:51 -0400 Subject: [PATCH] support "on" and "off" like the old strtobool --- coveo-settings/coveo_settings/bool_setting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coveo-settings/coveo_settings/bool_setting.py b/coveo-settings/coveo_settings/bool_setting.py index 5face4d7..c5c9176e 100644 --- a/coveo-settings/coveo_settings/bool_setting.py +++ b/coveo-settings/coveo_settings/bool_setting.py @@ -10,13 +10,13 @@ class BoolSetting(Setting[bool]): For instance, empty objects (strings, lists, dicts) or None will raise an exception. """ - TRUE_VALUES = ("true", "yes", "1", "y") - FALSE_VALUES = ("false", "no", "0", "n") + TRUE_VALUES = ("true", "yes", "1", "y", "on") + FALSE_VALUES = ("false", "no", "0", "n", "off") @staticmethod def _cast(value: ConfigValue) -> bool: """Converts any supported value to a bool.""" - value = str(value).lower() + value = str(value).casefold() if value not in BoolSetting.TRUE_VALUES + BoolSetting.FALSE_VALUES: raise ValueError(f"Cannot determine boolean from {value}")