villebro commented on a change in pull request #16107:
URL: https://github.com/apache/superset/pull/16107#discussion_r685914416
##########
File path: superset/utils/core.py
##########
@@ -423,6 +423,35 @@ def cast_to_num(value: Optional[Union[float, int, str]])
-> Optional[Union[float
return None
+def cast_to_boolean(value: Any) -> bool:
+ """Casts a value to an int/float
+
+ >>> cast_to_boolean(1)
+ True
+ >>> cast_to_boolean(0)
+ False
+ >>> cast_to_boolean(0.5)
+ True
+ >>> cast_to_boolean('true')
+ True
+ >>> cast_to_boolean('false')
+ False
+ >>> cast_to_boolean('False')
+ False
Review comment:
Nit: I would also add this as it seems to be missing
```python
>>> cast_to_boolean('True')
True
```
--
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]