Use node_typing for ANY -inputs

This commit is contained in:
kijai 2025-07-04 13:04:18 +03:00
parent 40d9d84b68
commit ee0eb6696b

View File

@ -2,8 +2,7 @@ import torch
import torch.nn as nn import torch.nn as nn
import numpy as np import numpy as np
from PIL import Image from PIL import Image
from typing import Union import json, re, os, io, time
import json, re, os, io, time, platform
import re import re
import importlib import importlib
@ -11,17 +10,11 @@ from comfy import model_management
import folder_paths import folder_paths
from nodes import MAX_RESOLUTION from nodes import MAX_RESOLUTION
from comfy.utils import common_upscale, ProgressBar, load_torch_file from comfy.utils import common_upscale, ProgressBar, load_torch_file
from comfy.comfy_types.node_typing import IO
script_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) script_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
folder_paths.add_model_folder_path("kjnodes_fonts", os.path.join(script_directory, "fonts")) folder_paths.add_model_folder_path("kjnodes_fonts", os.path.join(script_directory, "fonts"))
class AnyType(str):
"""A special class that is always equal in not equal comparisons. Credit to pythongosssss"""
def __ne__(self, __value: object) -> bool:
return False
any = AnyType("*")
class BOOLConstant: class BOOLConstant:
@classmethod @classmethod
def INPUT_TYPES(s): def INPUT_TYPES(s):
@ -615,13 +608,13 @@ class VRAM_Debug:
"unload_all_models": ("BOOLEAN", {"default": False}), "unload_all_models": ("BOOLEAN", {"default": False}),
}, },
"optional": { "optional": {
"any_input": (any, {}), "any_input": (IO.ANY,),
"image_pass": ("IMAGE",), "image_pass": ("IMAGE",),
"model_pass": ("MODEL",), "model_pass": ("MODEL",),
} }
} }
RETURN_TYPES = (any, "IMAGE","MODEL","INT", "INT",) RETURN_TYPES = (IO.ANY, "IMAGE","MODEL","INT", "INT",)
RETURN_NAMES = ("any_output", "image_pass", "model_pass", "freemem_before", "freemem_after") RETURN_NAMES = ("any_output", "image_pass", "model_pass", "freemem_before", "freemem_after")
FUNCTION = "VRAMdebug" FUNCTION = "VRAMdebug"
CATEGORY = "KJNodes/misc" CATEGORY = "KJNodes/misc"
@ -655,7 +648,7 @@ class SomethingToString:
def INPUT_TYPES(s): def INPUT_TYPES(s):
return { return {
"required": { "required": {
"input": (any, {}), "input": (IO.ANY, ),
}, },
"optional": { "optional": {
"prefix": ("STRING", {"default": ""}), "prefix": ("STRING", {"default": ""}),
@ -688,12 +681,12 @@ class Sleep:
def INPUT_TYPES(s): def INPUT_TYPES(s):
return { return {
"required": { "required": {
"input": (any, {}), "input": (IO.ANY, ),
"minutes": ("INT", {"default": 0, "min": 0, "max": 1439}), "minutes": ("INT", {"default": 0, "min": 0, "max": 1439}),
"seconds": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 59.99, "step": 0.01}), "seconds": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 59.99, "step": 0.01}),
}, },
} }
RETURN_TYPES = (any,) RETURN_TYPES = (IO.ANY,)
FUNCTION = "sleepdelay" FUNCTION = "sleepdelay"
CATEGORY = "KJNodes/misc" CATEGORY = "KJNodes/misc"
DESCRIPTION = """ DESCRIPTION = """
@ -820,7 +813,7 @@ class WidgetToString:
"return_all": ("BOOLEAN", {"default": False}), "return_all": ("BOOLEAN", {"default": False}),
}, },
"optional": { "optional": {
"any_input": (any, {}), "any_input": (IO.ANY, ),
"node_title": ("STRING", {"multiline": False}), "node_title": ("STRING", {"multiline": False}),
"allowed_float_decimals": ("INT", {"default": 2, "min": 0, "max": 10, "tooltip": "Number of decimal places to display for float values"}), "allowed_float_decimals": ("INT", {"default": 2, "min": 0, "max": 10, "tooltip": "Number of decimal places to display for float values"}),
@ -916,11 +909,11 @@ class DummyOut:
def INPUT_TYPES(cls): def INPUT_TYPES(cls):
return { return {
"required": { "required": {
"any_input": (any, {}), "any_input": (IO.ANY, ),
} }
} }
RETURN_TYPES = (any,) RETURN_TYPES = (IO.ANY,)
FUNCTION = "dummy" FUNCTION = "dummy"
CATEGORY = "KJNodes/misc" CATEGORY = "KJNodes/misc"
OUTPUT_NODE = True OUTPUT_NODE = True
@ -2493,7 +2486,7 @@ class TimerNodeKJ:
def INPUT_TYPES(s): def INPUT_TYPES(s):
return { return {
"required": { "required": {
"any_input": (any, {}), "any_input": (IO.ANY, ),
"mode": (["start", "stop"],), "mode": (["start", "stop"],),
"name": ("STRING", {"default": "Timer"}), "name": ("STRING", {"default": "Timer"}),
}, },
@ -2502,7 +2495,7 @@ class TimerNodeKJ:
}, },
} }
RETURN_TYPES = (any, "TIMER", "INT", ) RETURN_TYPES = (IO.ANY, "TIMER", "INT", )
RETURN_NAMES = ("any_output", "timer", "time") RETURN_NAMES = ("any_output", "timer", "time")
FUNCTION = "timer" FUNCTION = "timer"
CATEGORY = "KJNodes/misc" CATEGORY = "KJNodes/misc"