Skip to content

Commit bc340e6

Browse files
committed
lint
1 parent e6c0d01 commit bc340e6

5 files changed

Lines changed: 134 additions & 80 deletions

File tree

dash/mcp/primitives/tools/tool_get_dash_component.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def call_tool(cls, tool_name: str, arguments: dict[str, Any]) -> CallToolResult:
7575
]
7676
msg = f"Component '{comp_id}' not found in static layout."
7777
if rendering_tools:
78-
msg += f" However, the following tools would modify it: {rendering_tools}."
78+
msg += (
79+
f" However, the following tools would modify it: {rendering_tools}."
80+
)
7981
msg += " Use the dash://components resource to see statically available component IDs."
8082
return CallToolResult(
8183
content=[TextContent(type="text", text=msg)],
@@ -122,6 +124,8 @@ def call_tool(cls, tool_name: str, arguments: dict[str, Any]) -> CallToolResult:
122124
)
123125

124126
return CallToolResult(
125-
content=[TextContent(type="text", text=json.dumps(structured, default=str))],
127+
content=[
128+
TextContent(type="text", text=json.dumps(structured, default=str))
129+
],
126130
structuredContent=structured,
127131
)

dash/mcp/primitives/tools/tools_callbacks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from dash.mcp.types import CallbackExecutionError, ToolNotFoundError
1414

1515
from .base import MCPToolProvider
16+
from .callback_utils import run_callback
1617
from .results import format_callback_response
1718

1819

@@ -31,8 +32,6 @@ def list_tools(cls) -> list[Tool]:
3132
@classmethod
3233
def call_tool(cls, tool_name: str, arguments: dict[str, Any]) -> CallToolResult:
3334
"""Execute a callback tool by name."""
34-
from .callback_utils import run_callback
35-
3635
callback_map = get_app().mcp_callback_map
3736
cb = callback_map.find_by_tool_name(tool_name)
3837
if cb is None:
Lines changed: 122 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

33
import typing # noqa: F401
4-
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
4+
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
55
from dash.development.base_component import Component, _explicitize_args
66

77
ComponentType = typing.Union[
@@ -20,126 +20,120 @@
2020

2121
class Table(Component):
2222
"""A Table component.
23-
This is a description of the component.
24-
It's multiple lines long.
23+
This is a description of the component.
24+
It's multiple lines long.
2525
26-
Keyword arguments:
26+
Keyword arguments:
2727
28-
- children (a list of or a singular dash component, string or number; optional)
28+
- children (a list of or a singular dash component, string or number; optional)
2929
30-
- id (string; optional)
30+
- id (string; optional)
3131
32-
- aria-* (string; optional)
32+
- aria-* (string; optional)
3333
34-
- customArrayProp (list; optional)
34+
- customArrayProp (list; optional)
3535
36-
- customProp (optional)
36+
- customProp (optional)
3737
38-
- data-* (string; optional)
38+
- data-* (string; optional)
3939
40-
- in (string; optional)
40+
- in (string; optional)
4141
42-
- optionalAny (boolean | number | string | dict | list; optional)
42+
- optionalAny (boolean | number | string | dict | list; optional)
4343
44-
- optionalArray (list; optional):
45-
Description of optionalArray.
44+
- optionalArray (list; optional):
45+
Description of optionalArray.
4646
47-
- optionalArrayOf (list of numbers; optional)
47+
- optionalArrayOf (list of numbers; optional)
4848
49-
- optionalBool (boolean; optional)
49+
- optionalBool (boolean; optional)
5050
51-
- optionalElement (dash component; optional)
51+
- optionalElement (dash component; optional)
5252
53-
- optionalEnum (a value equal to: 'News', 'Photos'; optional)
53+
- optionalEnum (a value equal to: 'News', 'Photos'; optional)
5454
55-
- optionalNode (a list of or a singular dash component, string or number; optional)
55+
- optionalNode (a list of or a singular dash component, string or number; optional)
5656
57-
- optionalNumber (number; default 42)
57+
- optionalNumber (number; default 42)
5858
59-
- optionalObject (dict; optional)
59+
- optionalObject (dict; optional)
6060
61-
- optionalObjectOf (dict with strings as keys and values of type number; optional)
61+
- optionalObjectOf (dict with strings as keys and values of type number; optional)
6262
63-
- optionalObjectWithExactAndNestedDescription (dict; optional)
63+
- optionalObjectWithExactAndNestedDescription (dict; optional)
6464
65-
`optionalObjectWithExactAndNestedDescription` is a dict with keys:
65+
`optionalObjectWithExactAndNestedDescription` is a dict with keys:
6666
67-
- color (string; optional)
67+
- color (string; optional)
6868
69-
- fontSize (number; optional)
69+
- fontSize (number; optional)
7070
71-
- figure (dict; optional):
72-
Figure is a plotly graph object.
71+
- figure (dict; optional):
72+
Figure is a plotly graph object.
7373
74-
`figure` is a dict with keys:
74+
`figure` is a dict with keys:
7575
76-
- data (list of dicts; optional):
77-
data is a collection of traces.
76+
- data (list of dicts; optional):
77+
data is a collection of traces.
7878
79-
- layout (dict; optional):
80-
layout describes the rest of the figure.
79+
- layout (dict; optional):
80+
layout describes the rest of the figure.
8181
82-
- optionalObjectWithShapeAndNestedDescription (dict; optional)
82+
- optionalObjectWithShapeAndNestedDescription (dict; optional)
8383
84-
`optionalObjectWithShapeAndNestedDescription` is a dict with keys:
84+
`optionalObjectWithShapeAndNestedDescription` is a dict with keys:
8585
86-
- color (string; optional)
86+
- color (string; optional)
8787
88-
- fontSize (number; optional)
88+
- fontSize (number; optional)
8989
90-
- figure (dict; optional):
91-
Figure is a plotly graph object.
90+
- figure (dict; optional):
91+
Figure is a plotly graph object.
9292
93-
`figure` is a dict with keys:
93+
`figure` is a dict with keys:
9494
95-
- data (list of dicts; optional):
96-
data is a collection of traces.
95+
- data (list of dicts; optional):
96+
data is a collection of traces.
9797
98-
- layout (dict; optional):
99-
layout describes the rest of the figure.
98+
- layout (dict; optional):
99+
layout describes the rest of the figure.
100100
101-
- optionalString (string; default 'hello world')
101+
- optionalString (string; default 'hello world')
102102
103-
- optionalUnion (string | number; optional)"""
104-
_children_props = ['optionalNode', 'optionalElement']
105-
_base_nodes = ['optionalNode', 'optionalElement', 'children']
106-
_namespace = 'TableComponents'
107-
_type = 'Table'
103+
- optionalUnion (string | number; optional)"""
104+
105+
_children_props = ["optionalNode", "optionalElement"]
106+
_base_nodes = ["optionalNode", "optionalElement", "children"]
107+
_namespace = "TableComponents"
108+
_type = "Table"
108109
OptionalObjectWithExactAndNestedDescriptionFigure = TypedDict(
109110
"OptionalObjectWithExactAndNestedDescriptionFigure",
110-
{
111-
"data": NotRequired[typing.Sequence[dict]],
112-
"layout": NotRequired[dict]
113-
}
111+
{"data": NotRequired[typing.Sequence[dict]], "layout": NotRequired[dict]},
114112
)
115113

116114
OptionalObjectWithExactAndNestedDescription = TypedDict(
117115
"OptionalObjectWithExactAndNestedDescription",
118-
{
116+
{
119117
"color": NotRequired[str],
120118
"fontSize": NotRequired[NumberType],
121-
"figure": NotRequired["OptionalObjectWithExactAndNestedDescriptionFigure"]
122-
}
119+
"figure": NotRequired["OptionalObjectWithExactAndNestedDescriptionFigure"],
120+
},
123121
)
124122

125123
OptionalObjectWithShapeAndNestedDescriptionFigure = TypedDict(
126124
"OptionalObjectWithShapeAndNestedDescriptionFigure",
127-
{
128-
"data": NotRequired[typing.Sequence[dict]],
129-
"layout": NotRequired[dict]
130-
}
125+
{"data": NotRequired[typing.Sequence[dict]], "layout": NotRequired[dict]},
131126
)
132127

133128
OptionalObjectWithShapeAndNestedDescription = TypedDict(
134129
"OptionalObjectWithShapeAndNestedDescription",
135-
{
130+
{
136131
"color": NotRequired[str],
137132
"fontSize": NotRequired[NumberType],
138-
"figure": NotRequired["OptionalObjectWithShapeAndNestedDescriptionFigure"]
139-
}
133+
"figure": NotRequired["OptionalObjectWithShapeAndNestedDescriptionFigure"],
134+
},
140135
)
141136

142-
143137
def __init__(
144138
self,
145139
children: typing.Optional[ComponentType] = None,
@@ -154,26 +148,79 @@ def __init__(
154148
optionalElement: typing.Optional[Component] = None,
155149
optionalMessage: typing.Optional[typing.Any] = None,
156150
optionalEnum: typing.Optional[Literal["News", "Photos"]] = None,
157-
optionalUnion: typing.Optional[typing.Union[str, NumberType, typing.Any]] = None,
151+
optionalUnion: typing.Optional[
152+
typing.Union[str, NumberType, typing.Any]
153+
] = None,
158154
optionalArrayOf: typing.Optional[typing.Sequence[NumberType]] = None,
159-
optionalObjectOf: typing.Optional[typing.Dict[typing.Union[str, float, int], NumberType]] = None,
160-
optionalObjectWithExactAndNestedDescription: typing.Optional["OptionalObjectWithExactAndNestedDescription"] = None,
161-
optionalObjectWithShapeAndNestedDescription: typing.Optional["OptionalObjectWithShapeAndNestedDescription"] = None,
155+
optionalObjectOf: typing.Optional[
156+
typing.Dict[typing.Union[str, float, int], NumberType]
157+
] = None,
158+
optionalObjectWithExactAndNestedDescription: typing.Optional[
159+
"OptionalObjectWithExactAndNestedDescription"
160+
] = None,
161+
optionalObjectWithShapeAndNestedDescription: typing.Optional[
162+
"OptionalObjectWithShapeAndNestedDescription"
163+
] = None,
162164
optionalAny: typing.Optional[typing.Any] = None,
163165
customProp: typing.Optional[typing.Any] = None,
164166
customArrayProp: typing.Optional[typing.Sequence[typing.Any]] = None,
165167
id: typing.Optional[typing.Union[str, dict]] = None,
166168
**kwargs
167169
):
168-
self._prop_names = ['children', 'id', 'aria-*', 'customArrayProp', 'customProp', 'data-*', 'in', 'optionalAny', 'optionalArray', 'optionalArrayOf', 'optionalBool', 'optionalElement', 'optionalEnum', 'optionalNode', 'optionalNumber', 'optionalObject', 'optionalObjectOf', 'optionalObjectWithExactAndNestedDescription', 'optionalObjectWithShapeAndNestedDescription', 'optionalString', 'optionalUnion']
169-
self._valid_wildcard_attributes = ['data-', 'aria-']
170-
self.available_properties = ['children', 'id', 'aria-*', 'customArrayProp', 'customProp', 'data-*', 'in', 'optionalAny', 'optionalArray', 'optionalArrayOf', 'optionalBool', 'optionalElement', 'optionalEnum', 'optionalNode', 'optionalNumber', 'optionalObject', 'optionalObjectOf', 'optionalObjectWithExactAndNestedDescription', 'optionalObjectWithShapeAndNestedDescription', 'optionalString', 'optionalUnion']
171-
self.available_wildcard_properties = ['data-', 'aria-']
172-
_explicit_args = kwargs.pop('_explicit_args')
170+
self._prop_names = [
171+
"children",
172+
"id",
173+
"aria-*",
174+
"customArrayProp",
175+
"customProp",
176+
"data-*",
177+
"in",
178+
"optionalAny",
179+
"optionalArray",
180+
"optionalArrayOf",
181+
"optionalBool",
182+
"optionalElement",
183+
"optionalEnum",
184+
"optionalNode",
185+
"optionalNumber",
186+
"optionalObject",
187+
"optionalObjectOf",
188+
"optionalObjectWithExactAndNestedDescription",
189+
"optionalObjectWithShapeAndNestedDescription",
190+
"optionalString",
191+
"optionalUnion",
192+
]
193+
self._valid_wildcard_attributes = ["data-", "aria-"]
194+
self.available_properties = [
195+
"children",
196+
"id",
197+
"aria-*",
198+
"customArrayProp",
199+
"customProp",
200+
"data-*",
201+
"in",
202+
"optionalAny",
203+
"optionalArray",
204+
"optionalArrayOf",
205+
"optionalBool",
206+
"optionalElement",
207+
"optionalEnum",
208+
"optionalNode",
209+
"optionalNumber",
210+
"optionalObject",
211+
"optionalObjectOf",
212+
"optionalObjectWithExactAndNestedDescription",
213+
"optionalObjectWithShapeAndNestedDescription",
214+
"optionalString",
215+
"optionalUnion",
216+
]
217+
self.available_wildcard_properties = ["data-", "aria-"]
218+
_explicit_args = kwargs.pop("_explicit_args")
173219
_locals = locals()
174220
_locals.update(kwargs) # For wildcard attrs and excess named props
175-
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
221+
args = {k: _locals[k] for k in _explicit_args if k != "children"}
176222

177223
super(Table, self).__init__(children=children, **args)
178224

225+
179226
setattr(Table, "__init__", _explicitize_args(Table.__init__))

tests/unit/mcp/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
if sys.version_info < (3, 10):
1010
collect_ignore_glob.append("*")
1111
else:
12-
from dash.mcp.primitives.tools import call_tool, list_tools # pylint: disable=wrong-import-position
12+
from dash.mcp.primitives.tools import (
13+
call_tool,
14+
list_tools,
15+
) # pylint: disable=wrong-import-position
1316
from dash.mcp.primitives.tools.callback_adapter_collection import ( # pylint: disable=wrong-import-position
1417
CallbackAdapterCollection,
1518
)

tests/unit/mcp/tools/test_tools_callbacks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class TestOutputSemanticSummary:
111111
@staticmethod
112112
def _adapter_with_outputs(outputs, docstring=None):
113113
from unittest.mock import Mock
114+
114115
adapter = Mock()
115116
adapter.outputs = outputs
116117
adapter._docstring = docstring

0 commit comments

Comments
 (0)