Skip to content

Commit 5a6df16

Browse files
committed
Update type hints and comments on to_bool()
1 parent 4ea11af commit 5a6df16

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cmd2/utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,14 @@ def strip_quotes(arg: str) -> str:
8989
return arg
9090

9191

92-
def to_bool(val: str) -> bool:
93-
"""Converts a string to a boolean based on its value.
94-
95-
:param val: string being converted
96-
:return: boolean value expressed in the string
92+
def to_bool(val: Any) -> bool:
93+
"""Converts anything to a boolean based on its value.
94+
95+
Strings like "True", "true", "False", and "false" return True, True, False, and False
96+
respectively. All other values are converted using bool()
97+
98+
:param val: value being converted
99+
:return: boolean value expressed in the passed in value
97100
:raises: ValueError if the string does not contain a value corresponding to a boolean value
98101
"""
99102
if isinstance(val, str):

0 commit comments

Comments
 (0)