🐛 fix(utilities.py): handle field_type with "typing_extensions" prefix in UtilitiesFrontendNode class

 feat(utilities.py): improve handling of field_type in UtilitiesFrontendNode class to support different formats

Fixes #707
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-04 18:12:28 -03:00
commit c8a5e0724d

View file

@ -12,8 +12,11 @@ class UtilitiesFrontendNode(FrontendNode):
FrontendNode.format_field(field, name)
# field.field_type could be "Literal['news', 'search', 'places', 'images']
# we need to convert it to a list
# It seems it could also be like "typing_extensions.['news', 'search', 'places', 'images']"
if "Literal" in field.field_type:
field.options = ast.literal_eval(field.field_type.replace("Literal", ""))
field_type = field.field_type.replace("typing_extensions.", "")
field_type = field_type.replace("Literal", "")
field.options = ast.literal_eval(field_type)
field.is_list = True
field.field_type = "str"