Skip to content

Commit

Permalink
Merge pull request #206 from coveooss/feat/strtobool-deprecation
Browse files Browse the repository at this point in the history
support "on" and "off" like the old strtobool
  • Loading branch information
jonapich authored Apr 24, 2024
2 parents e63e700 + 67453ac commit d0c84a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions coveo-settings/coveo_settings/bool_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down

0 comments on commit d0c84a7

Please sign in to comment.