diff --git a/tests/test_generate_popular_node_signatures.py b/tests/test_generate_popular_node_signatures.py index 62cbb02..3fe7f4c 100644 --- a/tests/test_generate_popular_node_signatures.py +++ b/tests/test_generate_popular_node_signatures.py @@ -718,6 +718,54 @@ NODE_CLASS_MAPPINGS = { self.assertEqual({}, result["nodes"]) self.assertEqual("no_static_nodes", result["pack"]["status"]) + def test_subscript_assignment_to_return_names_skips_node(self): + source = ''' +class SubscriptMutatedReturnNamesNode: + RETURN_TYPES = ("IMAGE",) + RETURN_NAMES = ["image"] + RETURN_NAMES[0] = "mask" + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": ("IMAGE",), + }, + } + + +NODE_CLASS_MAPPINGS = { + "SubscriptMutatedReturnNamesNode": SubscriptMutatedReturnNamesNode, +} +''' + result = self._extract_source(source, "subscript-mutated-return-names-pack") + + self.assertEqual({}, result["nodes"]) + self.assertEqual("no_static_nodes", result["pack"]["status"]) + + def test_missing_return_names_is_allowed(self): + source = ''' +class MissingReturnNamesNode: + RETURN_TYPES = ("IMAGE",) + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": ("IMAGE",), + }, + } + + +NODE_CLASS_MAPPINGS = { + "MissingReturnNamesNode": MissingReturnNamesNode, +} +''' + result = self._extract_source(source, "missing-return-names-pack") + + self.assertEqual([], result["nodes"]["MissingReturnNamesNode"]["output_names"]) + self.assertEqual("ok", result["pack"]["status"]) + def test_final_static_return_types_assignment_wins(self): source = ''' class FinalReturnTypesNode: diff --git a/tools/generate_popular_node_signatures.py b/tools/generate_popular_node_signatures.py index 12f9dd0..db5c4c5 100644 --- a/tools/generate_popular_node_signatures.py +++ b/tools/generate_popular_node_signatures.py @@ -419,8 +419,10 @@ def _class_attr(cls, name, env): continue if name in _bound_names(stmt): value = _INVALID - if value in (_MISSING, _INVALID): + if value is _MISSING: return None + if value is _INVALID: + return _INVALID return value @@ -539,6 +541,8 @@ def _signature_from_class(node_type, cls, display, pack_meta, env): input_types = _input_types(cls, env) return_types = _class_attr(cls, "RETURN_TYPES", env) return_names = _class_attr(cls, "RETURN_NAMES", env) + if return_types is _INVALID or return_names is _INVALID: + return None if not isinstance(input_types, dict) or not isinstance(return_types, (list, tuple)): return None