villebro commented on code in PR #24001:
URL: https://github.com/apache/superset/pull/24001#discussion_r1190804187


##########
tests/unit_tests/utils/test_core.py:
##########
@@ -84,3 +88,14 @@ def test_remove_extra_adhoc_filters(
 ) -> None:
     remove_extra_adhoc_filters(original)
     assert expected == original
+
+
+def test_parse_boolean_string():
+    true = ("y", "Y", "yes", "True", "t", "true", "True", "On", "on", "1")
+    false = ("n", "no", "f", "false", "off", "0", "Off", "No", "N", "foo")
+
+    for y in true:
+        assert parse_boolean_string(y)
+
+    for n in false:

Review Comment:
   same here - let's try to avoid having two utils doing pretty much the same 
thing



##########
superset/utils/core.py:
##########
@@ -1787,8 +1787,25 @@ def indexed(
     return idx
 
 
+def strtobool(val: str) -> bool:
+    """Convert a string representation of truth to true (1) or false (0).
+
+    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
+    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
+    'val' is anything else.
+
+    Original implementation from deprecated distutils.
+    """
+    val = val.lower()
+    if val in {"y", "yes", "t", "true", "on", "1"}:
+        return True
+    if val in {"n", "no", "f", "false", "off", "0"}:
+        return False
+    raise ValueError("invalid truth value %r" % (val,))

Review Comment:
   Just a thought: To simplify the code, would it be feasible to just place 
this logic inside `parse_boolean_string`?  Or at least consolidate these 
somehow and just use that one util function everywhere..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to