def str_to_bool(string: str) -> bool:
    """Cast a string to a boolean value.

    Args:
        string: String to be converted to a bool.

    Raises:
        ValueError: In case the string could not be converted to a bool.
    """
    strip = string.strip()
    if strip in [".True.", "True", "T", "true", ".true."]:
        return True
    elif strip in [".False.", "False", "F", "false", ".false."]:
        return False
    raise ValueError('Could not convert "{}" to a boolean.'.format(string))