mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 13:32:36 +08:00
Refactor code to use dictionary comprehension
In this commit, we have refactored the code to improve its readability and conciseness by replacing the traditional `for` loop with a dictionary comprehension. The original code iterated through `nodes.NODE_CLASS_MAPPINGS`, calling the `node_info` function for each element and populating the `out` dictionary. The refactored code achieves the same functionality but in a more Pythonic way. This refactoring not only makes the code more concise but also improves its maintainability and reduces the potential for errors. It adheres to Python's best practices for clean and efficient code, enhancing the overall quality of the codebase.
This commit is contained in:
parent
76cdc809bf
commit
09fc080ed1
@ -411,10 +411,8 @@ class PromptServer():
|
||||
|
||||
@routes.get("/object_info")
|
||||
async def get_object_info(request):
|
||||
out = {}
|
||||
for x in nodes.NODE_CLASS_MAPPINGS:
|
||||
out[x] = node_info(x)
|
||||
return web.json_response(out)
|
||||
node_info_dict = {node_name: node_info(node_name) for node_name in nodes.NODE_CLASS_MAPPINGS}
|
||||
return web.json_response(node_info_dict)
|
||||
|
||||
@routes.get("/object_info/{node_class}")
|
||||
async def get_object_info_node(request):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user