Skip to content

Instantly share code, notes, and snippets.

@CheeseCake87
Last active June 15, 2024 09:44
Show Gist options
  • Save CheeseCake87/02bba8baa04baf5260f924364b06e657 to your computer and use it in GitHub Desktop.
Save CheeseCake87/02bba8baa04baf5260f924364b06e657 to your computer and use it in GitHub Desktop.
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