Fix type matching with AnyType class

- 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 <noreply@anthropic.com>
This commit is contained in:
jessesep
2025-12-05 01:52:01 +01:00
co-authored by Claude
parent afba842a33
commit 42d994649e
+17 -4
View File
@@ -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"