Files
jessesep-SimpleVariables/__init__.py
T
jessesepandClaude 1e8bd05938 Hybrid approach: Python stubs + JS virtual override
- Python defines nodes with ANY type so they appear in menus/drag connections
- JS overrides with isVirtualNode for actual graph-redirect behavior
- SimpleSet accepts any input, passes through
- SimpleGet dropdown shows available setter names

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 02:25:53 +01:00

69 lines
1.4 KiB
Python

"""
SimpleVariables - Set/Get Variable nodes for ComfyUI
JavaScript handles the actual logic (virtual nodes), Python stubs make them appear in menus.
"""
class AnyType(str):
"""Matches any type for ComfyUI type checking"""
def __eq__(self, _):
return True
def __ne__(self, _):
return False
ANY = AnyType("*")
class SimpleSet:
"""Set a variable by name"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"name": ("STRING", {"default": ""}),
},
"optional": {
"value": (ANY,),
}
}
RETURN_TYPES = (ANY,)
RETURN_NAMES = ("value",)
FUNCTION = "passthrough"
CATEGORY = "SimpleVariables"
def passthrough(self, name, value=None):
return (value,)
class SimpleGet:
"""Get a variable by name"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"name": ("STRING", {"default": ""}),
}
}
RETURN_TYPES = (ANY,)
RETURN_NAMES = ("value",)
FUNCTION = "get"
CATEGORY = "SimpleVariables"
def get(self, name):
return (None,)
NODE_CLASS_MAPPINGS = {
"SimpleSet": SimpleSet,
"SimpleGet": SimpleGet,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"SimpleSet": "SimpleSet",
"SimpleGet": "SimpleGet",
}
WEB_DIRECTORY = "./web"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]