From 42d994649e5181f5ac01fb0ed1f79a448543488c Mon Sep 17 00:00:00 2001 From: jessesep Date: Fri, 5 Dec 2025 01:52:01 +0100 Subject: [PATCH] Fix type matching with AnyType class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added AnyType class that bypasses ComfyUI type validation - This fixes "Return type mismatch" errors with wildcards - Pattern used by ComfyUI_essentials and other popular nodes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- __init__.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index aecac21..44472f8 100644 --- a/__init__.py +++ b/__init__.py @@ -2,6 +2,19 @@ SimpleVariables - Set and Get nodes for storing/retrieving any data by name in ComfyUI """ + +class AnyType(str): + """A special type that bypasses ComfyUI's type checking - always matches any type.""" + def __eq__(self, _): + return True + + def __ne__(self, _): + return False + + +# Create the any type instance +ANY = AnyType("*") + # Global storage for variables _variable_storage = {} @@ -37,10 +50,10 @@ class SetVariable: "variable_name": ("STRING", {"default": "my_var"}), }, "optional": { - "value": ("*",), + "value": (ANY,), } } - RETURN_TYPES = ("*",) + RETURN_TYPES = (ANY,) RETURN_NAMES = ("value",) FUNCTION = "set_var" CATEGORY = "variables" @@ -65,10 +78,10 @@ class GetVariable: "variable_name": ("STRING", {"default": "my_var"}), }, "optional": { - "trigger": ("*",), # Connect to SetVariable output to ensure execution order + "trigger": (ANY,), # Connect to SetVariable output to ensure execution order } } - RETURN_TYPES = ("*",) + RETURN_TYPES = (ANY,) RETURN_NAMES = ("value",) FUNCTION = "get_var" CATEGORY = "variables"