From e31f7a1128f4200cd1e7128bb4fd269d7edd477d Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Tue, 4 Nov 2025 16:06:26 -0800 Subject: [PATCH] Fixed providing list of allowed_types --- comfy_api/latest/_io.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/comfy_api/latest/_io.py b/comfy_api/latest/_io.py index 7f378da72..a887350e2 100644 --- a/comfy_api/latest/_io.py +++ b/comfy_api/latest/_io.py @@ -4,6 +4,7 @@ import copy import inspect from abc import ABC, abstractmethod from collections import Counter +from collections.abc import Iterable from dataclasses import asdict, dataclass from enum import Enum from typing import Any, Callable, Literal, TypedDict, TypeVar, TYPE_CHECKING @@ -882,12 +883,22 @@ class MatchType(ComfyTypeIO): class Template: def __init__(self, template_id: str, allowed_types: _ComfyType | list[_ComfyType] = AnyType): self.template_id = template_id - self.allowed_types = [allowed_types] if issubclass(allowed_types, _ComfyType) else allowed_types + # account for syntactic sugar + if not isinstance(allowed_types, Iterable): + allowed_types = [allowed_types] + for t in allowed_types: + if not isinstance(t, type): + if not isinstance(t, _ComfyType): + raise ValueError(f"Allowed types must be a ComfyType or a list of ComfyTypes, got {t.__class__.__name__}") + else: + if not issubclass(t, _ComfyType): + raise ValueError(f"Allowed types must be a ComfyType or a list of ComfyTypes, got {t.__name__}") + self.allowed_types = allowed_types def as_dict(self): return { "template_id": self.template_id, - "allowed_types": "".join(t.io_type for t in self.allowed_types), + "allowed_types": ",".join([t.io_type for t in self.allowed_types]), } class Input(DynamicInput):