From 607093e9cd3da5eab7d4899a158808a3c1eddb07 Mon Sep 17 00:00:00 2001 From: StableLlama Date: Sat, 31 Jan 2026 19:05:41 +0100 Subject: [PATCH] Fix list generation --- src/basic_data_handling/data_list_nodes.py | 24 +++++++-------- src/basic_data_handling/list_nodes.py | 8 ++--- tests/test_data_list_nodes.py | 36 +++++++++++----------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/basic_data_handling/data_list_nodes.py b/src/basic_data_handling/data_list_nodes.py index f7dc76d..7ec7f01 100644 --- a/src/basic_data_handling/data_list_nodes.py +++ b/src/basic_data_handling/data_list_nodes.py @@ -41,8 +41,8 @@ class DataListCreate(ComfyNodeABC): OUTPUT_IS_LIST = (True,) def create_list(self, **kwargs: list[Any]) -> tuple[list]: - values = list(kwargs.values()) - return (values[:-1],) + values = list(kwargs.values())[:-1] + return (values,) class DataListListCreate(ComfyNodeABC): @@ -71,8 +71,8 @@ class DataListListCreate(ComfyNodeABC): INPUT_IS_LIST = True def create_list(self, **kwargs: list[Any]) -> tuple[list]: - values = list(kwargs.values()) - return (values[:-1],) + values = list(kwargs.values())[:-1] + return (values,) class DataListCreateFromBoolean(ComfyNodeABC): @@ -98,8 +98,8 @@ class DataListCreateFromBoolean(ComfyNodeABC): OUTPUT_IS_LIST = (True,) def create_list(self, **kwargs: list[Any]) -> tuple[list]: - values = [bool(value) for value in kwargs.values()] - return (values[:-1],) + values = [bool(value) for value in list(kwargs.values())[:-1]] + return (values,) class DataListCreateFromFloat(ComfyNodeABC): @@ -125,8 +125,8 @@ class DataListCreateFromFloat(ComfyNodeABC): OUTPUT_IS_LIST = (True,) def create_list(self, **kwargs: list[Any]) -> tuple[list]: - values = [float(value) for value in kwargs.values()] - return (values[:-1],) + values = [float(value) for value in list(kwargs.values())[:-1]] + return (values,) class DataListCreateFromInt(ComfyNodeABC): @@ -152,8 +152,8 @@ class DataListCreateFromInt(ComfyNodeABC): OUTPUT_IS_LIST = (True,) def create_list(self, **kwargs: list[Any]) -> tuple[list]: - values = [int(value) for value in kwargs.values()] - return (values[:-1],) + values = [int(value) for value in list(kwargs.values())[:-1]] + return (values,) class DataListCreateFromString(ComfyNodeABC): @@ -179,8 +179,8 @@ class DataListCreateFromString(ComfyNodeABC): OUTPUT_IS_LIST = (True,) def create_list(self, **kwargs: list[Any]) -> tuple[list[Any]]: - values = [str(value) for value in kwargs.values()] - return (values[:-1],) + values = [str(value) for value in list(kwargs.values())[:-1]] + return (values,) class DataListAll(ComfyNodeABC): diff --git a/src/basic_data_handling/list_nodes.py b/src/basic_data_handling/list_nodes.py index b4ae7ae..966cd23 100644 --- a/src/basic_data_handling/list_nodes.py +++ b/src/basic_data_handling/list_nodes.py @@ -39,8 +39,8 @@ class ListCreate(ComfyNodeABC): FUNCTION = "create_list" def create_list(self, **kwargs: list[Any]) -> tuple[list[Any]]: - values = list(kwargs.values()) - return (values[:-1],) + values = list(kwargs.values())[:-1] + return (values,) class ListCreateFromBoolean(ComfyNodeABC): @@ -64,8 +64,8 @@ class ListCreateFromBoolean(ComfyNodeABC): FUNCTION = "create_list" def create_list(self, **kwargs: list[Any]) -> tuple[list[Any]]: - values = [bool(value) for value in kwargs.values()] - return (values[:-1],) + values = [bool(value) for value in list(kwargs.values())[:-1]] + return (values,) class ListCreateFromFloat(ComfyNodeABC): diff --git a/tests/test_data_list_nodes.py b/tests/test_data_list_nodes.py index aa6d9e4..45e1894 100644 --- a/tests/test_data_list_nodes.py +++ b/tests/test_data_list_nodes.py @@ -183,75 +183,75 @@ def test_filter_select(): def test_create(): node = DataListCreate() # Testing with one item - assert node.create_list(item_0="test", _dynamic_number=1) == (["test"],) + assert node.create_list(item_0="test", item_1="") == (["test"],) # Testing with multiple items of different types - assert node.create_list(item_0=1, item_1="two", item_2=3.0, _dynamic_number=3) == ([1, "two", 3.0],) + assert node.create_list(item_0=1, item_1="two", item_2=3.0, item_3="") == ([1, "two", 3.0],) # Testing with empty list (no items) - assert node.create_list(_dynamic_number=0) == ([],) + assert node.create_list(item_0="") == ([],) def test_create_from_boolean(): node = DataListCreateFromBoolean() # Testing with boolean values - assert node.create_list(item_0=True, item_1=False, _dynamic_number=2) == ([True, False],) + assert node.create_list(item_0=True, item_1=False, item_2=False) == ([True, False],) # Testing with boolean-convertible values - assert node.create_list(item_0=1, item_1=0, _dynamic_number=2) == ([True, False],) + assert node.create_list(item_0=1, item_1=0, item_2="") == ([True, False],) # Testing with empty list - assert node.create_list(_dynamic_number=0) == ([],) + assert node.create_list(item_0=0) == ([],) def test_create_from_float(): node = DataListCreateFromFloat() # Testing with float values - assert node.create_list(item_0=1.5, item_1=2.5, _dynamic_number=2) == ([1.5, 2.5],) + assert node.create_list(item_0=1.5, item_1=2.5, item_2=2) == ([1.5, 2.5],) # Testing with float-convertible values - assert node.create_list(item_0=1, item_1="2.5", _dynamic_number=2) == ([1.0, 2.5],) + assert node.create_list(item_0=1, item_1="2.5", item_2="") == ([1.0, 2.5],) # Testing with empty list - assert node.create_list(_dynamic_number=0) == ([],) + assert node.create_list(item_0="") == ([],) def test_create_from_int(): node = DataListCreateFromInt() # Testing with integer values - assert node.create_list(item_0=1, item_1=2, _dynamic_number=2) == ([1, 2],) + assert node.create_list(item_0=1, item_1=2, item_2="") == ([1, 2],) # Testing with int-convertible values - assert node.create_list(item_0="1", item_1=2.0, _dynamic_number=2) == ([1, 2],) + assert node.create_list(item_0="1", item_1=2.0, item_2="") == ([1, 2],) # Testing with empty list - assert node.create_list(_dynamic_number=0) == ([],) + assert node.create_list(item_0="") == ([],) def test_create_from_string(): node = DataListCreateFromString() # Testing with string values - assert node.create_list(item_0="hello", item_1="world", _dynamic_number=2) == (["hello", "world"],) + assert node.create_list(item_0="hello", item_1="world", item_2="") == (["hello", "world"],) # Testing with string-convertible values - assert node.create_list(item_0=123, item_1=True, _dynamic_number=2) == (["123", "True"],) + assert node.create_list(item_0=123, item_1=True, item_2="") == (["123", "True"],) # Testing with empty list - assert node.create_list(_dynamic_number=0) == ([],) + assert node.create_list(item_0="") == ([],) def test_list_create(): node = DataListListCreate() # Testing with string values - assert (node.create_list(item_0=["hello", "world"], item_1=["bye", "bye!"], _dynamic_number=2) == + assert (node.create_list(item_0=["hello", "world"], item_1=["bye", "bye!"], item_2="") == ([["hello", "world"], ["bye", "bye!"]],)) # Testing with mixed values - assert (node.create_list(item_0=[123, 456], item_1=[True, False], _dynamic_number=2) == + assert (node.create_list(item_0=[123, 456], item_1=[True, False], item_2="") == ([[123, 456], [True, False]],)) # Testing with empty list - assert node.create_list(_dynamic_number=0) == ([],) + assert node.create_list(item_0="") == ([],) def test_pop_random():