Switching to tuples removed this case
Checking if an element is in a small tuple is fast enough.
This commit is contained in:
parent
1967be0eb6
commit
028797bd24
|
@ -131,14 +131,11 @@ def to_bool(val):
|
||||||
"""
|
"""
|
||||||
if isinstance(val, str):
|
if isinstance(val, str):
|
||||||
val = val.lower()
|
val = val.lower()
|
||||||
try:
|
|
||||||
if val in (True, "true", "t", "yes", "y", "on", "1", 1):
|
if val in (True, "true", "t", "yes", "y", "on", "1", 1):
|
||||||
return True
|
return True
|
||||||
if val in (False, "false", "f", "no", "n", "off", "0", 0):
|
if val in (False, "false", "f", "no", "n", "off", "0", 0):
|
||||||
return False
|
return False
|
||||||
except TypeError:
|
|
||||||
# Raised when "val" is not hashable (e.g., lists)
|
|
||||||
pass
|
|
||||||
|
|
||||||
msg = f"Cannot convert value to bool: {val!r}"
|
msg = f"Cannot convert value to bool: {val!r}"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
Loading…
Reference in New Issue