Renamed InputV3, WidgetInputV3, OutputV3 to Input, WidgetInput, and Output

This commit is contained in:
Jedrzej Kosinski 2025-07-24 16:29:26 -07:00
parent 56aae3e2c8
commit d3a62a440f

View File

@ -156,7 +156,7 @@ class _IO_V3:
def Type(self): def Type(self):
return self.Parent.Type return self.Parent.Type
class InputV3(_IO_V3): class Input(_IO_V3):
''' '''
Base class for a V3 Input. Base class for a V3 Input.
''' '''
@ -180,7 +180,7 @@ class InputV3(_IO_V3):
def get_io_type(self): def get_io_type(self):
return _StringIOType(self.io_type) return _StringIOType(self.io_type)
class WidgetInputV3(InputV3): class WidgetInput(Input):
''' '''
Base class for a V3 Input with widget. Base class for a V3 Input with widget.
''' '''
@ -205,7 +205,7 @@ class WidgetInputV3(InputV3):
return self.widget_type if self.widget_type is not None else super().get_io_type() return self.widget_type if self.widget_type is not None else super().get_io_type()
class OutputV3(_IO_V3): class Output(_IO_V3):
def __init__(self, id: str=None, display_name: str=None, tooltip: str=None, def __init__(self, id: str=None, display_name: str=None, tooltip: str=None,
is_output_list=False): is_output_list=False):
self.id = id self.id = id
@ -226,12 +226,12 @@ class OutputV3(_IO_V3):
class ComfyTypeI(_ComfyType): class ComfyTypeI(_ComfyType):
'''ComfyType subclass that only has a default Input class - intended for types that only have Inputs.''' '''ComfyType subclass that only has a default Input class - intended for types that only have Inputs.'''
class Input(InputV3): class Input(Input):
... ...
class ComfyTypeIO(ComfyTypeI): class ComfyTypeIO(ComfyTypeI):
'''ComfyType subclass that has default Input and Output classes; useful for types with both Inputs and Outputs.''' '''ComfyType subclass that has default Input and Output classes; useful for types with both Inputs and Outputs.'''
class Output(OutputV3): class Output(Output):
... ...
@ -239,7 +239,7 @@ class ComfyTypeIO(ComfyTypeI):
class Boolean(ComfyTypeIO): class Boolean(ComfyTypeIO):
Type = bool Type = bool
class Input(WidgetInputV3): class Input(WidgetInput):
'''Boolean input.''' '''Boolean input.'''
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
default: bool=None, label_on: str=None, label_off: str=None, default: bool=None, label_on: str=None, label_off: str=None,
@ -259,7 +259,7 @@ class Boolean(ComfyTypeIO):
class Int(ComfyTypeIO): class Int(ComfyTypeIO):
Type = int Type = int
class Input(WidgetInputV3): class Input(WidgetInput):
'''Integer input.''' '''Integer input.'''
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
default: int=None, min: int=None, max: int=None, step: int=None, control_after_generate: bool=None, default: int=None, min: int=None, max: int=None, step: int=None, control_after_generate: bool=None,
@ -285,7 +285,7 @@ class Int(ComfyTypeIO):
class Float(ComfyTypeIO): class Float(ComfyTypeIO):
Type = float Type = float
class Input(WidgetInputV3): class Input(WidgetInput):
'''Float input.''' '''Float input.'''
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
default: float=None, min: float=None, max: float=None, step: float=None, round: float=None, default: float=None, min: float=None, max: float=None, step: float=None, round: float=None,
@ -311,7 +311,7 @@ class Float(ComfyTypeIO):
class String(ComfyTypeIO): class String(ComfyTypeIO):
Type = str Type = str
class Input(WidgetInputV3): class Input(WidgetInput):
'''String input.''' '''String input.'''
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
multiline=False, placeholder: str=None, default: str=None, dynamic_prompts: bool=None, multiline=False, placeholder: str=None, default: str=None, dynamic_prompts: bool=None,
@ -332,7 +332,7 @@ class String(ComfyTypeIO):
@comfytype(io_type="COMBO") @comfytype(io_type="COMBO")
class Combo(ComfyTypeI): class Combo(ComfyTypeI):
Type = str Type = str
class Input(WidgetInputV3): class Input(WidgetInput):
"""Combo input (dropdown).""" """Combo input (dropdown)."""
Type = str Type = str
def __init__(self, id: str, options: list[str]=None, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, def __init__(self, id: str, options: list[str]=None, display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None,
@ -397,7 +397,7 @@ class WanCameraEmbedding(ComfyTypeIO):
class Webcam(ComfyTypeIO): class Webcam(ComfyTypeIO):
Type = str Type = str
class Input(WidgetInputV3): class Input(WidgetInput):
"""Webcam input.""" """Webcam input."""
Type = str Type = str
def __init__( def __init__(
@ -714,14 +714,14 @@ class AnyType(ComfyTypeIO):
@comfytype(io_type="COMFY_MULTITYPED_V3") @comfytype(io_type="COMFY_MULTITYPED_V3")
class MultiType: class MultiType:
Type = Any Type = Any
class Input(InputV3): class Input(Input):
''' '''
Input that permits more than one input type; if `id` is an instance of `ComfyType.Input`, then that input will be used to create a widget (if applicable) with overridden values. Input that permits more than one input type; if `id` is an instance of `ComfyType.Input`, then that input will be used to create a widget (if applicable) with overridden values.
''' '''
def __init__(self, id: str | InputV3, types: list[type[_ComfyType] | _ComfyType], display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None): def __init__(self, id: str | Input, types: list[type[_ComfyType] | _ComfyType], display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None):
# if id is an Input, then use that Input with overridden values # if id is an Input, then use that Input with overridden values
self.input_override = None self.input_override = None
if isinstance(id, InputV3): if isinstance(id, Input):
self.input_override = copy.copy(id) self.input_override = copy.copy(id)
optional = id.optional if id.optional is True else optional optional = id.optional if id.optional is True else optional
tooltip = id.tooltip if id.tooltip is not None else tooltip tooltip = id.tooltip if id.tooltip is not None else tooltip
@ -729,13 +729,13 @@ class MultiType:
lazy = id.lazy if id.lazy is not None else lazy lazy = id.lazy if id.lazy is not None else lazy
id = id.id id = id.id
# if is a widget input, make sure widget_type is set appropriately # if is a widget input, make sure widget_type is set appropriately
if isinstance(self.input_override, WidgetInputV3): if isinstance(self.input_override, WidgetInput):
self.input_override.widget_type = self.input_override.get_io_type() self.input_override.widget_type = self.input_override.get_io_type()
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict) super().__init__(id, display_name, optional, tooltip, lazy, extra_dict)
self._io_types = types self._io_types = types
@property @property
def io_types(self) -> list[type[InputV3]]: def io_types(self) -> list[type[Input]]:
''' '''
Returns list of InputV3 class types permitted. Returns list of InputV3 class types permitted.
''' '''
@ -760,15 +760,15 @@ class MultiType:
else: else:
return super().as_dict() return super().as_dict()
class DynamicInput(InputV3, ABC): class DynamicInput(Input, ABC):
''' '''
Abstract class for dynamic input registration. Abstract class for dynamic input registration.
''' '''
@abstractmethod @abstractmethod
def get_dynamic(self) -> list[InputV3]: def get_dynamic(self) -> list[Input]:
... ...
class DynamicOutput(OutputV3, ABC): class DynamicOutput(Output, ABC):
''' '''
Abstract class for dynamic output registration. Abstract class for dynamic output registration.
''' '''
@ -777,7 +777,7 @@ class DynamicOutput(OutputV3, ABC):
super().__init__(id, display_name, tooltip, is_output_list) super().__init__(id, display_name, tooltip, is_output_list)
@abstractmethod @abstractmethod
def get_dynamic(self) -> list[OutputV3]: def get_dynamic(self) -> list[Output]:
... ...
@ -785,7 +785,7 @@ class DynamicOutput(OutputV3, ABC):
class AutogrowDynamic(ComfyTypeI): class AutogrowDynamic(ComfyTypeI):
Type = list[Any] Type = list[Any]
class Input(DynamicInput): class Input(DynamicInput):
def __init__(self, id: str, template_input: InputV3, min: int=1, max: int=None, def __init__(self, id: str, template_input: Input, min: int=1, max: int=None,
display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None): display_name: str=None, optional=False, tooltip: str=None, lazy: bool=None, extra_dict=None):
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict) super().__init__(id, display_name, optional, tooltip, lazy, extra_dict)
self.template_input = template_input self.template_input = template_input
@ -796,7 +796,7 @@ class AutogrowDynamic(ComfyTypeI):
self.min = min self.min = min
self.max = max self.max = max
def get_dynamic(self) -> list[InputV3]: def get_dynamic(self) -> list[Input]:
curr_count = 1 curr_count = 1
new_inputs = [] new_inputs = []
for i in range(self.min): for i in range(self.min):
@ -805,7 +805,7 @@ class AutogrowDynamic(ComfyTypeI):
if new_input.display_name is not None: if new_input.display_name is not None:
new_input.display_name = f"{new_input.display_name}{curr_count}" new_input.display_name = f"{new_input.display_name}{curr_count}"
new_input.optional = self.optional or new_input.optional new_input.optional = self.optional or new_input.optional
if isinstance(self.template_input, WidgetInputV3): if isinstance(self.template_input, WidgetInput):
new_input.force_input = True new_input.force_input = True
new_inputs.append(new_input) new_inputs.append(new_input)
curr_count += 1 curr_count += 1
@ -816,7 +816,7 @@ class AutogrowDynamic(ComfyTypeI):
if new_input.display_name is not None: if new_input.display_name is not None:
new_input.display_name = f"{new_input.display_name}{curr_count}" new_input.display_name = f"{new_input.display_name}{curr_count}"
new_input.optional = True new_input.optional = True
if isinstance(self.template_input, WidgetInputV3): if isinstance(self.template_input, WidgetInput):
new_input.force_input = True new_input.force_input = True
new_inputs.append(new_input) new_inputs.append(new_input)
curr_count += 1 curr_count += 1
@ -847,7 +847,7 @@ class MatchType(ComfyTypeIO):
super().__init__(id, display_name, optional, tooltip, lazy, extra_dict) super().__init__(id, display_name, optional, tooltip, lazy, extra_dict)
self.template = template self.template = template
def get_dynamic(self) -> list[InputV3]: def get_dynamic(self) -> list[Input]:
return [self] return [self]
def as_dict(self): def as_dict(self):
@ -861,7 +861,7 @@ class MatchType(ComfyTypeIO):
super().__init__(id, display_name, tooltip, is_output_list) super().__init__(id, display_name, tooltip, is_output_list)
self.template = template self.template = template
def get_dynamic(self) -> list[OutputV3]: def get_dynamic(self) -> list[Output]:
return [self] return [self]
def as_dict(self): def as_dict(self):
@ -965,8 +965,8 @@ class Schema:
"""Display name of node.""" """Display name of node."""
category: str = "sd" category: str = "sd"
"""The category of the node, as per the "Add Node" menu.""" """The category of the node, as per the "Add Node" menu."""
inputs: list[InputV3]=None inputs: list[Input]=None
outputs: list[OutputV3]=None outputs: list[Output]=None
hidden: list[Hidden]=None hidden: list[Hidden]=None
description: str="" description: str=""
"""Node description, shown as a tooltip when hovering over the node.""" """Node description, shown as a tooltip when hovering over the node."""
@ -1128,14 +1128,14 @@ class Schema:
return info return info
def add_to_dict_v1(i: InputV3, input: dict): def add_to_dict_v1(i: Input, input: dict):
key = "optional" if i.optional else "required" key = "optional" if i.optional else "required"
as_dict = i.as_dict() as_dict = i.as_dict()
# for v1, we don't want to include the optional key # for v1, we don't want to include the optional key
as_dict.pop("optional", None) as_dict.pop("optional", None)
input.setdefault(key, {})[i.id] = (i.get_io_type(), as_dict) input.setdefault(key, {})[i.id] = (i.get_io_type(), as_dict)
def add_to_dict_v3(io: InputV3 | OutputV3, d: dict): def add_to_dict_v3(io: Input | Output, d: dict):
d[io.id] = (io.get_io_type(), io.as_dict()) d[io.id] = (io.get_io_type(), io.as_dict())
@ -1536,9 +1536,9 @@ class _IO:
comfytype = staticmethod(comfytype) comfytype = staticmethod(comfytype)
Custom = staticmethod(Custom) Custom = staticmethod(Custom)
InputV3 = InputV3 Input = Input
WidgetInputV3 = WidgetInputV3 WidgetInput = WidgetInput
OutputV3 = OutputV3 Output = Output
ComfyTypeI = ComfyTypeI ComfyTypeI = ComfyTypeI
ComfyTypeIO = ComfyTypeIO ComfyTypeIO = ComfyTypeIO
#--------------------------------- #---------------------------------