🐛 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:
parent
92217155e4
commit
99bc9f01ba
1 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue