raise ValueError(
"unrecognised input string {}".format(string_input))
if type_str == "int":
return tuple(map(int, values))
if type_str == "float":
return tuple(map(float, values))
if type_str == "str":
return tuple(values)
After Change
regex = re.compile(STATEMENT)
matched_str = regex.match(string_input)
if matched_str:
filtered_groups = [matched for matched in matched_str.groups()
if matched is not None]
if not filtered_groups:
return ()
try:
values = [v.strip() for v in filtered_groups[0].split(",")]
except IndexError:
raise ValueError(
"unrecognised input string {}".format(string_input))
if type_str == "int":
return tuple(int(val) for val in values)
if type_str == "float":
return tuple(float(val) for val in values)
if type_str == "str":