88
99from __future__ import annotations
1010
11- import json
1211from typing import Any
1312
14- from dash ._layout_utils import find_matching_components , _WILDCARD_VALUES
13+ from dash ._layout_utils import (
14+ _WILDCARD_VALUES ,
15+ find_matching_components ,
16+ parse_wildcard_id ,
17+ )
1518from dash .mcp .types import MCPInput
1619
1720from .base import InputSchemaSource
@@ -26,7 +29,7 @@ class PatternMatchingSchema(InputSchemaSource):
2629
2730 @classmethod
2831 def get_schema (cls , param : MCPInput ) -> dict [str , Any ] | None :
29- dep_id = _parse_dep_id (param ["component_id" ])
32+ dep_id = parse_wildcard_id (param ["component_id" ])
3033 if dep_id is None :
3134 return None
3235
@@ -52,15 +55,6 @@ def get_schema(cls, param: MCPInput) -> dict[str, Any] | None:
5255 return {"type" : "array" , "items" : item_schema }
5356
5457
55- def _parse_dep_id (component_id : str ) -> dict | None :
56- if not component_id .startswith ("{" ):
57- return None
58- try :
59- return json .loads (component_id )
60- except (json .JSONDecodeError , ValueError ):
61- return None
62-
63-
6458def _get_wildcard_type (dep_id : dict ) -> str | None :
6559 """Return the wildcard type (ALL, MATCH, ALLSMALLER) or None."""
6660 for value in dep_id .values ():
@@ -72,10 +66,11 @@ def _get_wildcard_type(dep_id: dict) -> str | None:
7266
7367def _infer_value_schema (param : MCPInput ) -> dict [str , Any ] | None :
7468 """Infer the JSON Schema for the ``value`` field from a matching component."""
75- matches = find_matching_components (_parse_dep_id (param ["component_id" ]))
69+ matches = find_matching_components (parse_wildcard_id (param ["component_id" ]))
7670 if not matches :
7771 return None
7872
73+ # pylint: disable-next=cyclic-import,import-outside-toplevel
7974 from . import get_input_schema
8075
8176 concrete_param : MCPInput = {
0 commit comments