From 848ef8fa1c5f2f58a1dd96cbc9a2185df4e4d34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20LONLAS?= Date: Tue, 19 May 2026 00:49:04 +0800 Subject: [PATCH] fix: accept extra kwargs in LMStudioConnect.validate_inputs (#6) ComfyUI can pass any of a node's schema inputs to validate_inputs by name, depending on the schema version. The current signature only accepts server_url, timeout_seconds, and max_tokens, so extra inputs (api_token, model, reasoning_enabled, ...) would raise TypeError before validation ever runs. Add **_: Any to absorb any additional inputs ComfyUI provides while keeping the existing validation logic intact. Co-authored-by: Claude Opus 4.7 --- connect_node.py | 10 +++++++++- tests/test_connect_node.py | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/connect_node.py b/connect_node.py index 97105fc..e0bad45 100644 --- a/connect_node.py +++ b/connect_node.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import Any + from comfy_api.latest import io, ui from .client import ( @@ -115,7 +117,13 @@ class LMStudioConnect(io.ComfyNode): ) @classmethod - def validate_inputs(cls, server_url: str, timeout_seconds: int, max_tokens: int) -> bool | str: + def validate_inputs( + cls, + server_url: str, + timeout_seconds: int, + max_tokens: int, + **_: Any, + ) -> bool | str: try: normalize_server_url(server_url) except ValueError as exc: diff --git a/tests/test_connect_node.py b/tests/test_connect_node.py index 08be62b..9f482c3 100644 --- a/tests/test_connect_node.py +++ b/tests/test_connect_node.py @@ -49,6 +49,27 @@ def test_validate_inputs() -> None: assert cls.validate_inputs("http://127.0.0.1:1234", 10, 0) == "max_tokens must be >= 1" +def test_validate_inputs_accepts_extra_kwargs() -> None: + connect_node = _connect_module() + cls = connect_node.LMStudioConnect + + # ComfyUI may pass any of the schema inputs by name; the method must tolerate them. + assert ( + cls.validate_inputs( + "http://127.0.0.1:1234", + 10, + 128, + api_token="-", + model="placeholder", + reasoning_enabled=False, + use_tooling_mcp=False, + temperature=0.7, + test_connectivity=True, + ) + is True + ) + + def test_execute_with_placeholder_model_uses_discovered_default( monkeypatch: pytest.MonkeyPatch, ) -> None: