mirror of
https://github.com/Comfy-Org/ComfyUI.git
synced 2026-08-24 01:56:59 +08:00
Drop register_dynamic_input_func legacy-arity shim
register_dynamic_input_func is a private helper (underscore module, not in __all__, not re-exported). Its only callers are the three core setup_dynamic_input_funcs() registrations, all of which were updated together. No third party can be relying on the old 5-arg signature, so the inspect.signature shim and accompanying backward-compat tests are over-engineered. Amp-Thread-ID: https://ampcode.com/threads/T-019e8568-f382-743d-a97f-0de3ff29d501 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -1369,36 +1369,7 @@ _DynamicInputFunc = Callable[
|
||||
]
|
||||
DYNAMIC_INPUT_LOOKUP: dict[str, _DynamicInputFunc] = {}
|
||||
def register_dynamic_input_func(io_type: str, func: _DynamicInputFunc):
|
||||
"""Register a dynamic-input expansion callback.
|
||||
|
||||
Accepts both the current 6-argument form and the legacy 5-argument form
|
||||
(without ``live_input_types``). Legacy callables are silently wrapped so
|
||||
custom nodes that registered against the older signature continue to work.
|
||||
"""
|
||||
try:
|
||||
sig = inspect.signature(func)
|
||||
param_count = sum(
|
||||
1 for p in sig.parameters.values()
|
||||
if p.kind in (inspect.Parameter.POSITIONAL_ONLY,
|
||||
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
||||
inspect.Parameter.VAR_POSITIONAL)
|
||||
)
|
||||
# 5 = legacy signature (no live_input_types). If the callable has
|
||||
# *args we can't be certain, so treat it as new-style.
|
||||
has_varargs = any(p.kind is inspect.Parameter.VAR_POSITIONAL for p in sig.parameters.values())
|
||||
is_legacy = (param_count == 5 and not has_varargs)
|
||||
except (TypeError, ValueError):
|
||||
# Builtins / C-implemented callables without introspectable signatures
|
||||
# are assumed to be new-style.
|
||||
is_legacy = False
|
||||
|
||||
if is_legacy:
|
||||
_legacy = func
|
||||
def _adapter(out_dict, live_inputs, value, input_type, curr_prefix, live_input_types=None):
|
||||
_legacy(out_dict, live_inputs, value, input_type, curr_prefix)
|
||||
DYNAMIC_INPUT_LOOKUP[io_type] = _adapter
|
||||
else:
|
||||
DYNAMIC_INPUT_LOOKUP[io_type] = func
|
||||
DYNAMIC_INPUT_LOOKUP[io_type] = func
|
||||
|
||||
def get_dynamic_input_func(io_type: str) -> _DynamicInputFunc:
|
||||
return DYNAMIC_INPUT_LOOKUP[io_type]
|
||||
|
||||
Reference in New Issue
Block a user