55import random
66import uuid
77from io import BytesIO
8- from typing import Type
98
109import av
1110import numpy as np
@@ -83,7 +82,7 @@ def _convert_tensor_to_pil(image_tensor: torch.Tensor) -> PILImage.Image:
8382 return PILImage .fromarray (np .clip (255.0 * image_tensor .cpu ().numpy (), 0 , 255 ).astype (np .uint8 ))
8483
8584 @staticmethod
86- def _create_png_metadata (cls : Type [ComfyNode ] | None ) -> PngInfo | None :
85+ def _create_png_metadata (cls : type [ComfyNode ] | None ) -> PngInfo | None :
8786 """Creates a PngInfo object with prompt and extra_pnginfo."""
8887 if args .disable_metadata or cls is None or not cls .hidden :
8988 return None
@@ -96,7 +95,7 @@ def _create_png_metadata(cls: Type[ComfyNode] | None) -> PngInfo | None:
9695 return metadata
9796
9897 @staticmethod
99- def _create_animated_png_metadata (cls : Type [ComfyNode ] | None ) -> PngInfo | None :
98+ def _create_animated_png_metadata (cls : type [ComfyNode ] | None ) -> PngInfo | None :
10099 """Creates a PngInfo object with prompt and extra_pnginfo for animated PNGs (APNG)."""
101100 if args .disable_metadata or cls is None or not cls .hidden :
102101 return None
@@ -121,7 +120,7 @@ def _create_animated_png_metadata(cls: Type[ComfyNode] | None) -> PngInfo | None
121120 return metadata
122121
123122 @staticmethod
124- def _create_webp_metadata (pil_image : PILImage .Image , cls : Type [ComfyNode ] | None ) -> PILImage .Exif :
123+ def _create_webp_metadata (pil_image : PILImage .Image , cls : type [ComfyNode ] | None ) -> PILImage .Exif :
125124 """Creates EXIF metadata bytes for WebP images."""
126125 exif_data = pil_image .getexif ()
127126 if args .disable_metadata or cls is None or cls .hidden is None :
@@ -137,7 +136,7 @@ def _create_webp_metadata(pil_image: PILImage.Image, cls: Type[ComfyNode] | None
137136
138137 @staticmethod
139138 def save_images (
140- images , filename_prefix : str , folder_type : FolderType , cls : Type [ComfyNode ] | None , compress_level = 4 ,
139+ images , filename_prefix : str , folder_type : FolderType , cls : type [ComfyNode ] | None , compress_level = 4 ,
141140 ) -> list [SavedResult ]:
142141 """Saves a batch of images as individual PNG files."""
143142 full_output_folder , filename , counter , subfolder , _ = folder_paths .get_save_image_path (
@@ -155,7 +154,7 @@ def save_images(
155154 return results
156155
157156 @staticmethod
158- def get_save_images_ui (images , filename_prefix : str , cls : Type [ComfyNode ] | None , compress_level = 4 ) -> SavedImages :
157+ def get_save_images_ui (images , filename_prefix : str , cls : type [ComfyNode ] | None , compress_level = 4 ) -> SavedImages :
159158 """Saves a batch of images and returns a UI object for the node output."""
160159 return SavedImages (
161160 ImageSaveHelper .save_images (
@@ -169,7 +168,7 @@ def get_save_images_ui(images, filename_prefix: str, cls: Type[ComfyNode] | None
169168
170169 @staticmethod
171170 def save_animated_png (
172- images , filename_prefix : str , folder_type : FolderType , cls : Type [ComfyNode ] | None , fps : float , compress_level : int
171+ images , filename_prefix : str , folder_type : FolderType , cls : type [ComfyNode ] | None , fps : float , compress_level : int
173172 ) -> SavedResult :
174173 """Saves a batch of images as a single animated PNG."""
175174 full_output_folder , filename , counter , subfolder , _ = folder_paths .get_save_image_path (
@@ -191,7 +190,7 @@ def save_animated_png(
191190
192191 @staticmethod
193192 def get_save_animated_png_ui (
194- images , filename_prefix : str , cls : Type [ComfyNode ] | None , fps : float , compress_level : int
193+ images , filename_prefix : str , cls : type [ComfyNode ] | None , fps : float , compress_level : int
195194 ) -> SavedImages :
196195 """Saves an animated PNG and returns a UI object for the node output."""
197196 result = ImageSaveHelper .save_animated_png (
@@ -209,7 +208,7 @@ def save_animated_webp(
209208 images ,
210209 filename_prefix : str ,
211210 folder_type : FolderType ,
212- cls : Type [ComfyNode ] | None ,
211+ cls : type [ComfyNode ] | None ,
213212 fps : float ,
214213 lossless : bool ,
215214 quality : int ,
@@ -238,7 +237,7 @@ def save_animated_webp(
238237 def get_save_animated_webp_ui (
239238 images ,
240239 filename_prefix : str ,
241- cls : Type [ComfyNode ] | None ,
240+ cls : type [ComfyNode ] | None ,
242241 fps : float ,
243242 lossless : bool ,
244243 quality : int ,
@@ -267,7 +266,7 @@ def save_audio(
267266 audio : dict ,
268267 filename_prefix : str ,
269268 folder_type : FolderType ,
270- cls : Type [ComfyNode ] | None ,
269+ cls : type [ComfyNode ] | None ,
271270 format : str = "flac" ,
272271 quality : str = "128k" ,
273272 ) -> list [SavedResult ]:
@@ -372,7 +371,7 @@ def save_audio(
372371
373372 @staticmethod
374373 def get_save_audio_ui (
375- audio , filename_prefix : str , cls : Type [ComfyNode ] | None , format : str = "flac" , quality : str = "128k" ,
374+ audio , filename_prefix : str , cls : type [ComfyNode ] | None , format : str = "flac" , quality : str = "128k" ,
376375 ) -> SavedAudios :
377376 """Save and instantly wrap for UI."""
378377 return SavedAudios (
@@ -388,7 +387,7 @@ def get_save_audio_ui(
388387
389388
390389class PreviewImage (_UIOutput ):
391- def __init__ (self , image : Image .Type , animated : bool = False , cls : Type [ComfyNode ] = None , ** kwargs ):
390+ def __init__ (self , image : Image .Type , animated : bool = False , cls : type [ComfyNode ] = None , ** kwargs ):
392391 self .values = ImageSaveHelper .save_images (
393392 image ,
394393 filename_prefix = "ComfyUI_temp_" + '' .join (random .choice ("abcdefghijklmnopqrstupvxyz" ) for _ in range (5 )),
@@ -412,7 +411,7 @@ def __init__(self, mask: PreviewMask.Type, animated: bool=False, cls: ComfyNode=
412411
413412
414413class PreviewAudio (_UIOutput ):
415- def __init__ (self , audio : dict , cls : Type [ComfyNode ] = None , ** kwargs ):
414+ def __init__ (self , audio : dict , cls : type [ComfyNode ] = None , ** kwargs ):
416415 self .values = AudioSaveHelper .save_audio (
417416 audio ,
418417 filename_prefix = "ComfyUI_temp_" + "" .join (random .choice ("abcdefghijklmnopqrstuvwxyz" ) for _ in range (5 )),
0 commit comments