11from __future__ import annotations
2- from typing import Any , Literal , TYPE_CHECKING , TypeVar , Callable , Optional , cast , TypedDict
2+ from typing import Any , Literal , TypeVar , Callable , TypedDict
33from typing_extensions import NotRequired
44from enum import Enum
55from abc import ABC , abstractmethod
@@ -108,7 +108,7 @@ class ComfyType(ABC):
108108def comfytype (io_type : str , ** kwargs ):
109109 '''
110110 Decorator to mark nested classes as ComfyType; io_type will be bound to the class.
111-
111+
112112 A ComfyType may have the following attributes:
113113 - Type = <type hint here>
114114 - class Input(InputV3): ...
@@ -206,15 +206,15 @@ def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str
206206 self .socketless = socketless
207207 self .widgetType = widgetType
208208 self .force_input = force_input
209-
209+
210210 def as_dict_V1 (self ):
211211 return super ().as_dict_V1 () | prune_dict ({
212212 "default" : self .default ,
213213 "socketless" : self .socketless ,
214214 "widgetType" : self .widgetType ,
215215 "forceInput" : self .force_input ,
216216 })
217-
217+
218218 def get_io_type_V1 (self ):
219219 return self .widgetType if self .widgetType is not None else super ().get_io_type_V1 ()
220220
@@ -289,21 +289,21 @@ def __setattr__(self, key: str, value: Any):
289289 super ().__setattr__ (key , value )
290290 else :
291291 self .local_state [key ] = value
292-
292+
293293 def __setitem__ (self , key : str , value : Any ):
294294 self .local_state [key ] = value
295-
295+
296296 def __getitem__ (self , key : str ):
297297 return self .local_state [key ]
298-
298+
299299 def __delitem__ (self , key : str ):
300300 del self .local_state [key ]
301301
302302
303303@comfytype (io_type = "BOOLEAN" )
304304class Boolean (ComfyTypeIO ):
305305 Type = bool
306-
306+
307307 class Input (WidgetInputV3 ):
308308 '''Boolean input.'''
309309 def __init__ (self , id : str , display_name : str = None , optional = False , tooltip : str = None , lazy : bool = None ,
@@ -313,7 +313,7 @@ def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str
313313 self .label_on = label_on
314314 self .label_off = label_off
315315 self .default : bool
316-
316+
317317 def as_dict_V1 (self ):
318318 return super ().as_dict_V1 () | prune_dict ({
319319 "label_on" : self .label_on ,
@@ -385,7 +385,7 @@ def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str
385385 self .multiline = multiline
386386 self .placeholder = placeholder
387387 self .default : str
388-
388+
389389 def as_dict_V1 (self ):
390390 return super ().as_dict_V1 () | prune_dict ({
391391 "multiline" : self .multiline ,
@@ -500,7 +500,7 @@ class PooledDict(TypedDict):
500500 By default, the dimensions are based on total pixel amount, but the first value can be set to "percentage" to use a percentage of the image size instead.
501501
502502 (1024, 1024, 0, 0) would apply conditioning to the top-left 1024x1024 pixels.
503-
503+
504504 ("percentage", 0.5, 0.5, 0, 0) would apply conditioning to the top-left 50% of the image.''' # TODO: verify its actually top-left
505505 strength : NotRequired [float ]
506506 '''Strength of conditioning. Default strength is 1.0.'''
@@ -755,7 +755,7 @@ def __init__(self, id: str | InputV3, types: list[type[ComfyType] | ComfyType],
755755 self .input_override .widgetType = self .input_override .get_io_type_V1 ()
756756 super ().__init__ (id , display_name , optional , tooltip , lazy , extra_dict )
757757 self ._io_types = types
758-
758+
759759 @property
760760 def io_types (self ) -> list [type [InputV3 ]]:
761761 '''
@@ -768,14 +768,14 @@ def io_types(self) -> list[type[InputV3]]:
768768 else :
769769 io_types .append (x )
770770 return io_types
771-
771+
772772 def get_io_type_V1 (self ):
773773 # ensure types are unique and order is preserved
774774 str_types = [x .io_type for x in self .io_types ]
775775 if self .input_override is not None :
776776 str_types .insert (0 , self .input_override .get_io_type_V1 ())
777777 return "," .join (list (dict .fromkeys (str_types )))
778-
778+
779779 def as_dict_V1 (self ):
780780 if self .input_override is not None :
781781 return self .input_override .as_dict_V1 () | super ().as_dict_V1 ()
@@ -870,7 +870,7 @@ def __init__(self, unique_id: str, prompt: Any,
870870 def __getattr__ (self , key : str ):
871871 '''If hidden variable not found, return None.'''
872872 return None
873-
873+
874874 @classmethod
875875 def from_dict (cls , d : dict | None ):
876876 if d is None :
@@ -1088,7 +1088,7 @@ class ComfyNodeV3:
10881088
10891089 RELATIVE_PYTHON_MODULE = None
10901090 SCHEMA = None
1091-
1091+
10921092 # filled in during execution
10931093 state : NodeState = None
10941094 resources : Resources = None
@@ -1097,28 +1097,24 @@ class ComfyNodeV3:
10971097 @classmethod
10981098 @abstractmethod
10991099 def DEFINE_SCHEMA (cls ) -> SchemaV3 :
1100- """
1101- Override this function with one that returns a SchemaV3 instance.
1102- """
1103- return None
1104- DEFINE_SCHEMA = None
1100+ """Override this function with one that returns a SchemaV3 instance."""
1101+ raise NotImplementedError
11051102
11061103 @classmethod
11071104 @abstractmethod
11081105 def execute (cls , ** kwargs ) -> NodeOutput :
1109- pass
1110- execute = None
1106+ raise NotImplementedError
11111107
11121108 @classmethod
11131109 def validate_inputs (cls , ** kwargs ) -> bool :
1114- """Optionally, define this function to validate inputs; equivalnet to V1's VALIDATE_INPUTS."""
1115- pass
1116- validate_inputs = None
1110+ """Optionally, define this function to validate inputs; equivalent to V1's VALIDATE_INPUTS."""
1111+ raise NotImplementedError
11171112
11181113 @classmethod
11191114 def fingerprint_inputs (cls , ** kwargs ) -> Any :
11201115 """Optionally, define this function to fingerprint inputs; equivalent to V1's IS_CHANGED."""
1121- pass
1116+ raise NotImplementedError
1117+
11221118 fingerprint_inputs = None
11231119
11241120 @classmethod
@@ -1135,8 +1131,8 @@ def check_lazy_status(cls, **kwargs) -> list[str]:
11351131
11361132 Comfy Docs: https://docs.comfy.org/custom-nodes/backend/lazy_evaluation#defining-check-lazy-status
11371133 """
1138- need = [name for name in kwargs if kwargs [name ] is None ]
1139- return need
1134+ return [name for name in kwargs if kwargs [name ] is None ]
1135+
11401136 check_lazy_status = None
11411137
11421138 @classmethod
@@ -1405,7 +1401,7 @@ def result(self):
14051401 @classmethod
14061402 def from_dict (cls , data : dict [str , Any ]) -> "NodeOutput" :
14071403 args = ()
1408- ui = None
1404+ ui = None
14091405 expand = None
14101406 if "result" in data :
14111407 result = data ["result" ]
0 commit comments