Last active
June 15, 2024 09:44
-
-
Save CheeseCake87/02bba8baa04baf5260f924364b06e657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing as t | |
def is_truly(value: t.Optional[t.Union[str, bool, int]]) -> bool: | |
if isinstance(value, int): | |
return True if value > 0 else False | |
if isinstance(value, bool): | |
return value | |
if isinstance(value, str): | |
if value.lower() in ("true", "yes", "y", "1"): | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment