🐛 fix(custom_component.py): improve parsing of return type in CustomComponent class
✨ feat(custom_component.py): add support for parsing return type when it is a Union of types in CustomComponent class
This commit is contained in:
parent
639550d537
commit
d16d916952
1 changed files with 9 additions and 9 deletions
|
|
@ -118,15 +118,15 @@ class CustomComponent(Component, extra=Extra.allow):
|
||||||
|
|
||||||
build_method = build_methods[0]
|
build_method = build_methods[0]
|
||||||
return_type = build_method["return_type"]
|
return_type = build_method["return_type"]
|
||||||
# It could be a type or a Union[type1, type2]
|
# If the return type is not a Union, then we just return it as a list
|
||||||
if "Union" in return_type:
|
if "Union" not in return_type:
|
||||||
return_type = (
|
return [return_type] if return_type in self.return_type_valid_list else []
|
||||||
return_type.replace("Union", "").replace("[", "").replace("]", "")
|
|
||||||
)
|
# If the return type is a Union, then we need to parse it
|
||||||
return_type = return_type.split(",")
|
return_type = return_type.replace("Union", "").replace("[", "").replace("]", "")
|
||||||
return_type = [item.strip() for item in return_type]
|
return_type = return_type.split(",")
|
||||||
return [item for item in return_type if item in self.return_type_valid_list]
|
return_type = [item.strip() for item in return_type]
|
||||||
return build_method["return_type"]
|
return [item for item in return_type if item in self.return_type_valid_list]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_main_class_name(self):
|
def get_main_class_name(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue