summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2022-11-05 20:24:25 -0600
committerkotfu <kotfu@kotfu.net>2022-11-05 20:24:25 -0600
commit5a6df16b2d6cad842a87f055ff688f818571132b (patch)
tree480b3a7d3283899fb1c571dcb5f54f9573f1af0a
parent4ea11af39e78caa0a722791e408336395a113497 (diff)
downloadcmd2-git-5a6df16b2d6cad842a87f055ff688f818571132b.tar.gz
Update type hints and comments on to_bool()
-rw-r--r--cmd2/utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index e193b4db..d1edfce9 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -89,11 +89,14 @@ def strip_quotes(arg: str) -> str:
return arg
-def to_bool(val: str) -> bool:
- """Converts a string to a boolean based on its value.
-
- :param val: string being converted
- :return: boolean value expressed in the string
+def to_bool(val: Any) -> bool:
+ """Converts anything to a boolean based on its value.
+
+ Strings like "True", "true", "False", and "false" return True, True, False, and False
+ respectively. All other values are converted using bool()
+
+ :param val: value being converted
+ :return: boolean value expressed in the passed in value
:raises: ValueError if the string does not contain a value corresponding to a boolean value
"""
if isinstance(val, str):