refactor: Update Vertex class to improve handling of template_dicts inputs

Refactor the Vertex class to improve the handling of template_dicts inputs. Instead of using list comprehensions, the code now uses explicit loops to append the required and optional inputs. This change enhances the readability and maintainability of the code.
This commit is contained in:
ogabrielluiz 2024-06-13 16:30:38 -03:00
commit 88f03f0408

View file

@ -234,16 +234,15 @@ class Vertex:
self.has_session_id = "session_id" in template_dicts self.has_session_id = "session_id" in template_dicts
self.required_inputs = [ self.required_inputs = []
template_dicts[key]["type"] for key, value in template_dicts.items() if value["required"] self.optional_inputs = []
] for value_dict in template_dicts.values():
self.optional_inputs = [ list_to_append = self.required_inputs if value_dict.get("required") else self.optional_inputs
template_dicts[key]["type"] for key, value in template_dicts.items() if not value["required"]
] if "type" in value_dict:
# Add the template_dicts[key]["input_types"] to the optional_inputs list_to_append.append(value_dict["type"])
self.optional_inputs.extend( elif "input_types" in value_dict:
[input_type for value in template_dicts.values() for input_type in value.get("input_types", [])] list_to_append.extend(value_dict["input_types"])
)
template_dict = self.data["node"]["template"] template_dict = self.data["node"]["template"]
self.vertex_type = ( self.vertex_type = (