🐛 fix(custom.py): evaluate items in split_item list using ast.literal_eval to handle cases where items are not strings

The code now uses ast.literal_eval to evaluate each item in the split_item list. This is done to handle cases where the items are not strings and cannot be directly converted to their respective types. This ensures that the output_list contains correctly evaluated items.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-07 01:34:37 -03:00
commit 99bc9f01ba

View file

@ -88,6 +88,14 @@ class CustomComponent(BaseModel):
# If there isn't a type, append None
else:
split_item.append(None)
for i in range(len(split_item)):
try:
# Try to evaluate the item
split_item[i] = ast.literal_eval(split_item[i])
except ValueError:
# If it fails, just pass
pass
output_list.append(split_item)
return output_list