def parse_bool(val):
    """
    Attempt to convert an environment variable into a boolean. Recommend using True or
    False as the boolean values but can also use 1 or 0.
    """
    if isinstance(val, str):
        # Try true/false strings
        if val.lower().startswith('f'):
            return False
        if val.lower().startswith('t'):
            return True

        # Try integer strings
        val = int(val)
    return bool(val)