def str_to_bool(string):
  """Converts a case-insensitive string 'true' or 'false' into a bool.

  Args:
    string: String to convert. Either 'true' or 'false', case-insensitive.

  Raises:
    ValueError if string is not 'true' or 'false'.
  """
  lower_string = string.lower()

  if lower_string == 'true':
    return True

  if lower_string == 'false':
    return False

  raise ValueError('Expected "true" or "false"; got "{}".'.format(string))