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):
|
||||
val = val.lower()
|
||||
try:
|
||||
if val in (True, "true", "t", "yes", "y", "on", "1", 1):
|
||||
return True
|
||||
if val in (False, "false", "f", "no", "n", "off", "0", 0):
|
||||
return False
|
||||
except TypeError:
|
||||
# Raised when "val" is not hashable (e.g., lists)
|
||||
pass
|
||||
|
||||
if val in (True, "true", "t", "yes", "y", "on", "1", 1):
|
||||
return True
|
||||
if val in (False, "false", "f", "no", "n", "off", "0", 0):
|
||||
return False
|
||||
|
||||
msg = f"Cannot convert value to bool: {val!r}"
|
||||
raise ValueError(msg)
|
||||
|
|
Loading…
Reference in New Issue