From ee25d74c5c903585781b590ead548ffe25171a5f Mon Sep 17 00:00:00 2001 From: czgu Date: Fri, 18 Oct 2024 12:41:18 -0700 Subject: [PATCH] fix: Make str to bool noop if input is bool (#1499) * fix: Make str to bool noop if input is bool * update typing --- querybook/server/lib/utils/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/querybook/server/lib/utils/utils.py b/querybook/server/lib/utils/utils.py index 5206c23ca..d1add40ec 100644 --- a/querybook/server/lib/utils/utils.py +++ b/querybook/server/lib/utils/utils.py @@ -162,8 +162,10 @@ def get_default_args(func): } -def str_to_bool(value: Optional[str]) -> bool: +def str_to_bool(value: Optional[Union[str, bool]]) -> bool: if value is None: return False + if isinstance(value, bool): + return value return value.lower() in ("yes", "true", "t", "1")