Skip to content

Commit 598a6f9

Browse files
committed
chore: Delint
1 parent 8c83ef9 commit 598a6f9

File tree

6 files changed

+83
-21
lines changed

6 files changed

+83
-21
lines changed

packages/toolbox-langchain/src/toolbox_langchain/async_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ async def aload_tool(
9494
)
9595
auth_token_getters = auth_tokens
9696

97-
9897
url = f"{self.__url}/api/tool/{tool_name}"
9998
manifest: ManifestSchema = await _load_manifest(url, self.__session)
10099

packages/toolbox-langchain/src/toolbox_langchain/client.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ async def aload_tool(
114114
"""
115115
async_tool = await self.__run_as_async(
116116
self.__async_client.aload_tool(
117-
tool_name, auth_token_getters, auth_tokens, auth_headers, bound_params, strict
117+
tool_name,
118+
auth_token_getters,
119+
auth_tokens,
120+
auth_headers,
121+
bound_params,
122+
strict,
118123
)
119124
)
120125

@@ -153,7 +158,12 @@ async def aload_toolset(
153158
"""
154159
async_tools = await self.__run_as_async(
155160
self.__async_client.aload_toolset(
156-
toolset_name, auth_token_getters, auth_tokens, auth_headers, bound_params, strict
161+
toolset_name,
162+
auth_token_getters,
163+
auth_tokens,
164+
auth_headers,
165+
bound_params,
166+
strict,
157167
)
158168
)
159169

@@ -194,7 +204,12 @@ def load_tool(
194204
"""
195205
async_tool = self.__run_as_sync(
196206
self.__async_client.aload_tool(
197-
tool_name, auth_token_getters, auth_tokens, auth_headers, bound_params, strict
207+
tool_name,
208+
auth_token_getters,
209+
auth_tokens,
210+
auth_headers,
211+
bound_params,
212+
strict,
198213
)
199214
)
200215

@@ -233,7 +248,12 @@ def load_toolset(
233248
"""
234249
async_tools = self.__run_as_sync(
235250
self.__async_client.aload_toolset(
236-
toolset_name, auth_token_getters, auth_tokens, auth_headers, bound_params, strict
251+
toolset_name,
252+
auth_token_getters,
253+
auth_tokens,
254+
auth_headers,
255+
bound_params,
256+
strict,
237257
)
238258
)
239259

packages/toolbox-langchain/tests/test_async_tools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,16 @@ async def test_toolbox_tool_add_auth_token_getters(
176176
for source, getter in expected_auth_token_getters.items():
177177
assert tool._AsyncToolboxTool__auth_token_getters[source]() == getter()
178178

179-
async def test_toolbox_tool_add_auth_token_getters_duplicate(self, auth_toolbox_tool):
179+
async def test_toolbox_tool_add_auth_token_getters_duplicate(
180+
self, auth_toolbox_tool
181+
):
180182
tool = auth_toolbox_tool.add_auth_token_getters(
181183
{"test-auth-source": lambda: "test-token"}
182184
)
183185
with pytest.raises(ValueError) as e:
184-
tool = tool.add_auth_token_getters({"test-auth-source": lambda: "test-token"})
186+
tool = tool.add_auth_token_getters(
187+
{"test-auth-source": lambda: "test-token"}
188+
)
185189
assert (
186190
"Authentication source(s) `test-auth-source` already registered in tool `test_tool`."
187191
in str(e.value)

packages/toolbox-langchain/tests/test_client.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def test_load_tool_with_args(self, mock_aload_tool, toolbox_client):
134134
assert tool.description == mock_tool.description
135135
assert tool.args_schema == mock_tool.args_schema
136136
mock_aload_tool.assert_called_once_with(
137-
"test_tool_name", auth_token_getters, auth_tokens, auth_headers, bound_params, False
137+
"test_tool_name",
138+
auth_token_getters,
139+
auth_tokens,
140+
auth_headers,
141+
bound_params,
142+
False,
138143
)
139144

140145
@patch("toolbox_langchain.client.AsyncToolboxClient.aload_toolset")
@@ -148,7 +153,6 @@ def test_load_toolset_with_args(self, mock_aload_toolset, toolbox_client):
148153
mock_tools[1].args_schema = BaseModel
149154
mock_aload_toolset.return_value = mock_tools
150155

151-
152156
auth_token_getters = {"token_getter1": lambda: "value1"}
153157
auth_tokens = {"token1": lambda: "value2"}
154158
auth_headers = {"header1": lambda: "value3"}
@@ -171,7 +175,12 @@ def test_load_toolset_with_args(self, mock_aload_toolset, toolbox_client):
171175
for a, b in zip(tools, mock_tools)
172176
)
173177
mock_aload_toolset.assert_called_once_with(
174-
"my_toolset", auth_token_getters, auth_tokens, auth_headers, bound_params, False
178+
"my_toolset",
179+
auth_token_getters,
180+
auth_tokens,
181+
auth_headers,
182+
bound_params,
183+
False,
175184
)
176185

177186
@pytest.mark.asyncio
@@ -189,13 +198,23 @@ async def test_aload_tool_with_args(self, mock_aload_tool, toolbox_client):
189198
bound_params = {"param1": "value4"}
190199

191200
tool = await toolbox_client.aload_tool(
192-
"test_tool", auth_token_getters, auth_tokens, auth_headers, bound_params, False
201+
"test_tool",
202+
auth_token_getters,
203+
auth_tokens,
204+
auth_headers,
205+
bound_params,
206+
False,
193207
)
194208
assert tool.name == mock_tool.name
195209
assert tool.description == mock_tool.description
196210
assert tool.args_schema == mock_tool.args_schema
197211
mock_aload_tool.assert_called_once_with(
198-
"test_tool", auth_token_getters, auth_tokens, auth_headers, bound_params, False
212+
"test_tool",
213+
auth_token_getters,
214+
auth_tokens,
215+
auth_headers,
216+
bound_params,
217+
False,
199218
)
200219

201220
@pytest.mark.asyncio
@@ -216,7 +235,12 @@ async def test_aload_toolset_with_args(self, mock_aload_toolset, toolbox_client)
216235
bound_params = {"param1": "value4"}
217236

218237
tools = await toolbox_client.aload_toolset(
219-
"my_toolset", auth_token_getters, auth_tokens, auth_headers, bound_params, False
238+
"my_toolset",
239+
auth_token_getters,
240+
auth_tokens,
241+
auth_headers,
242+
bound_params,
243+
False,
220244
)
221245
assert len(tools) == len(mock_tools)
222246
assert all(
@@ -226,5 +250,10 @@ async def test_aload_toolset_with_args(self, mock_aload_toolset, toolbox_client)
226250
for a, b in zip(tools, mock_tools)
227251
)
228252
mock_aload_toolset.assert_called_once_with(
229-
"my_toolset", auth_token_getters, auth_tokens, auth_headers, bound_params, False
253+
"my_toolset",
254+
auth_token_getters,
255+
auth_tokens,
256+
auth_headers,
257+
bound_params,
258+
False,
230259
)

packages/toolbox-langchain/tests/test_e2e.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ async def test_run_tool_param_auth_no_auth(self, toolbox):
164164
async def test_run_tool_param_auth(self, toolbox, auth_token1):
165165
"""Tests running a tool with a param requiring auth, with correct auth."""
166166
tool = await toolbox.aload_tool(
167-
"get-row-by-email-auth", auth_token_getters={"my-test-auth": lambda: auth_token1}
167+
"get-row-by-email-auth",
168+
auth_token_getters={"my-test-auth": lambda: auth_token1},
168169
)
169170
response = await tool.ainvoke({})
170171
assert "row4" in response
@@ -174,7 +175,8 @@ async def test_run_tool_param_auth(self, toolbox, auth_token1):
174175
async def test_run_tool_param_auth_no_field(self, toolbox, auth_token1):
175176
"""Tests running a tool with a param requiring auth, with insufficient auth."""
176177
tool = await toolbox.aload_tool(
177-
"get-row-by-content-auth", auth_token_getters={"my-test-auth": lambda: auth_token1}
178+
"get-row-by-content-auth",
179+
auth_token_getters={"my-test-auth": lambda: auth_token1},
178180
)
179181
with pytest.raises(
180182
ToolException,
@@ -304,7 +306,8 @@ def test_run_tool_param_auth_no_auth(self, toolbox):
304306
def test_run_tool_param_auth(self, toolbox, auth_token1):
305307
"""Tests running a tool with a param requiring auth, with correct auth."""
306308
tool = toolbox.load_tool(
307-
"get-row-by-email-auth", auth_token_getters={"my-test-auth": lambda: auth_token1}
309+
"get-row-by-email-auth",
310+
auth_token_getters={"my-test-auth": lambda: auth_token1},
308311
)
309312
response = tool.invoke({})
310313
assert "row4" in response
@@ -314,7 +317,8 @@ def test_run_tool_param_auth(self, toolbox, auth_token1):
314317
def test_run_tool_param_auth_no_field(self, toolbox, auth_token1):
315318
"""Tests running a tool with a param requiring auth, with insufficient auth."""
316319
tool = toolbox.load_tool(
317-
"get-row-by-content-auth", auth_token_getters={"my-test-auth": lambda: auth_token1}
320+
"get-row-by-content-auth",
321+
auth_token_getters={"my-test-auth": lambda: auth_token1},
318322
)
319323
with pytest.raises(
320324
ToolException,

packages/toolbox-langchain/tests/test_tools.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,21 @@ def test_toolbox_tool_add_auth_token_getters(
188188
)
189189

190190
tool = auth_toolbox_tool.add_auth_token_getters(auth_token_getters)
191-
mock_async_auth_tool.add_auth_token_getters.assert_called_once_with(auth_token_getters, True)
191+
mock_async_auth_tool.add_auth_token_getters.assert_called_once_with(
192+
auth_token_getters, True
193+
)
192194
for source, getter in expected_auth_token_getters.items():
193195
assert (
194-
tool._ToolboxTool__async_tool._AsyncToolboxTool__auth_token_getters[source]()
196+
tool._ToolboxTool__async_tool._AsyncToolboxTool__auth_token_getters[
197+
source
198+
]()
195199
== getter()
196200
)
197201
assert isinstance(tool, ToolboxTool)
198202

199-
def test_toolbox_tool_add_auth_token_getter(self, mock_async_auth_tool, auth_toolbox_tool):
203+
def test_toolbox_tool_add_auth_token_getter(
204+
self, mock_async_auth_tool, auth_toolbox_tool
205+
):
200206
get_id_token = lambda: "test-token"
201207
expected_auth_token_getters = {"test-auth-source": get_id_token}
202208
auth_toolbox_tool._ToolboxTool__async_tool._AsyncToolboxTool__auth_token_getters = (

0 commit comments

Comments
 (0)