Skip to content

Commit ad131cf

Browse files
committed
chore: Delint
1 parent d4f5559 commit ad131cf

File tree

5 files changed

+38
-25
lines changed

5 files changed

+38
-25
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
from warnings import warn
1717

1818
from aiohttp import ClientSession
19+
from toolbox_core.client import ToolboxClient as ToolboxCoreClient
1920

2021
from .async_tools import AsyncToolboxTool
21-
from toolbox_core.client import ToolboxClient as ToolboxCoreClient
2222

2323

2424
# This class is an internal implementation detail and is not exposed to the
@@ -92,7 +92,7 @@ async def aload_tool(
9292
core_tool = await self.__core_client.load_tool(
9393
name=tool_name,
9494
auth_token_getters=auth_token_getters,
95-
bound_params=bound_params
95+
bound_params=bound_params,
9696
)
9797
return AsyncToolboxTool(core_tool=core_tool)
9898

@@ -157,7 +157,7 @@ async def aload_toolset(
157157
name=toolset_name,
158158
auth_token_getters=auth_token_getters,
159159
bound_params=bound_params,
160-
strict=strict
160+
strict=strict,
161161
)
162162

163163
tools = []

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from toolbox_core.tool import ToolboxTool as ToolboxCoreTool
1919

2020

21-
2221
# This class is an internal implementation detail and is not exposed to the
2322
# end-user. It should not be used directly by external code. Changes to this
2423
# class will not be considered breaking changes to the public API.
@@ -64,8 +63,6 @@ async def _arun(self, **kwargs: Any) -> str:
6463
"""
6564
return await self.__core_tool(**kwargs)
6665

67-
68-
6966
def add_auth_token_getters(
7067
self, auth_token_getters: dict[str, Callable[[], str]]
7168
) -> "AsyncToolboxTool":

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515
import asyncio
16-
from warnings import warn
1716
from typing import Any, Callable, Optional, Union
17+
from warnings import warn
1818

19-
from .tools import ToolboxTool
2019
from toolbox_core.sync_client import ToolboxSyncClient as ToolboxCoreSyncClient
2120
from toolbox_core.sync_tool import ToolboxSyncTool
2221

22+
from .tools import ToolboxTool
2323

2424

2525
class ToolboxClient:
@@ -88,7 +88,7 @@ async def aload_tool(
8888
coro = self.__core_sync_client._ToolboxSyncClient__async_client.load_tool(
8989
name=tool_name,
9090
auth_token_getters=auth_token_getters,
91-
bound_params=bound_params
91+
bound_params=bound_params,
9292
)
9393

9494
if not self.__core_sync_client._ToolboxSyncClient__loop:
@@ -97,10 +97,16 @@ async def aload_tool(
9797
else:
9898
# Otherwise, run in the background thread.
9999
core_tool = await asyncio.wrap_future(
100-
asyncio.run_coroutine_threadsafe(coro, self.__core_sync_client._ToolboxSyncClient__loop)
100+
asyncio.run_coroutine_threadsafe(
101+
coro, self.__core_sync_client._ToolboxSyncClient__loop
102+
)
101103
)
102104

103-
core_sync_tool = ToolboxSyncTool(core_tool, self.__core_sync_client._ToolboxSyncClient__loop, self.__core_sync_client._ToolboxSyncClient__thread)
105+
core_sync_tool = ToolboxSyncTool(
106+
core_tool,
107+
self.__core_sync_client._ToolboxSyncClient__loop,
108+
self.__core_sync_client._ToolboxSyncClient__thread,
109+
)
104110
return ToolboxTool(core_sync_tool=core_sync_tool)
105111

106112
async def aload_toolset(
@@ -164,7 +170,7 @@ async def aload_toolset(
164170
name=toolset_name,
165171
auth_token_getters=auth_token_getters,
166172
bound_params=bound_params,
167-
strict=strict
173+
strict=strict,
168174
)
169175

170176
if not self.__core_sync_client._ToolboxSyncClient__loop:
@@ -173,11 +179,17 @@ async def aload_toolset(
173179
else:
174180
# Otherwise, run in the background thread.
175181
core_tools = await asyncio.wrap_future(
176-
asyncio.run_coroutine_threadsafe(coro, self.__core_sync_client._ToolboxSyncClient__loop)
182+
asyncio.run_coroutine_threadsafe(
183+
coro, self.__core_sync_client._ToolboxSyncClient__loop
184+
)
177185
)
178186

179187
core_sync_tools = [
180-
ToolboxSyncTool(core_tool, self.__core_sync_client._ToolboxSyncClient__loop, self.__core_sync_client._ToolboxSyncClient__thread)
188+
ToolboxSyncTool(
189+
core_tool,
190+
self.__core_sync_client._ToolboxSyncClient__loop,
191+
self.__core_sync_client._ToolboxSyncClient__thread,
192+
)
181193
for core_tool in core_tools
182194
]
183195
tools = []
@@ -237,7 +249,7 @@ def load_tool(
237249
core_sync_tool = self.__core_sync_client.load_tool(
238250
name=tool_name,
239251
auth_token_getters=auth_token_getters,
240-
bound_params=bound_params
252+
bound_params=bound_params,
241253
)
242254
return ToolboxTool(core_sync_tool=core_sync_tool)
243255

@@ -302,7 +314,7 @@ def load_toolset(
302314
name=toolset_name,
303315
auth_token_getters=auth_token_getters,
304316
bound_params=bound_params,
305-
strict=strict
317+
strict=strict,
306318
)
307319

308320
tools = []

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from toolbox_core.sync_tool import ToolboxSyncTool as ToolboxCoreSyncTool
2020

2121

22-
2322
class ToolboxTool(BaseTool):
2423
"""
2524
A subclass of LangChain's BaseTool that supports features specific to
@@ -58,10 +57,11 @@ async def _arun(self, **kwargs: Any) -> dict[str, Any]:
5857

5958
# Otherwise, run in the background thread.
6059
return await asyncio.wrap_future(
61-
asyncio.run_coroutine_threadsafe(coro, self.__core_sync_tool._ToolboxSyncTool__loop)
60+
asyncio.run_coroutine_threadsafe(
61+
coro, self.__core_sync_tool._ToolboxSyncTool__loop
62+
)
6263
)
6364

64-
6565
def add_auth_token_getters(
6666
self, auth_token_getters: dict[str, Callable[[], str]]
6767
) -> "ToolboxTool":
@@ -81,10 +81,11 @@ def add_auth_token_getters(
8181
ValueError: If any of the provided auth parameters is already
8282
registered.
8383
"""
84-
new_core_sync_tool = self.__core_sync_tool.add_auth_token_getters(auth_token_getters)
84+
new_core_sync_tool = self.__core_sync_tool.add_auth_token_getters(
85+
auth_token_getters
86+
)
8587
return ToolboxTool(core_sync_tool=new_core_sync_tool)
8688

87-
8889
def add_auth_token_getter(
8990
self, auth_source: str, get_id_token: Callable[[], str]
9091
) -> "ToolboxTool":

packages/toolbox-langchain/tests/test_e2e.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ async def test_run_tool_unauth_with_auth(self, toolbox, auth_token2):
119119
match="Validation failed for tool 'get-row-by-id': unused auth tokens: my-test-auth.",
120120
):
121121
await toolbox.aload_tool(
122-
"get-row-by-id", auth_token_getters={"my-test-auth": lambda: auth_token2}
122+
"get-row-by-id",
123+
auth_token_getters={"my-test-auth": lambda: auth_token2},
123124
)
124125

125126
async def test_run_tool_no_auth(self, toolbox):
@@ -182,10 +183,11 @@ async def test_run_tool_param_auth_no_field(self, toolbox, auth_token1):
182183
)
183184
with pytest.raises(
184185
Exception,
185-
match="provided parameters were invalid: error parsing authenticated parameter \"data\": no field named row_data in claims"
186+
match='provided parameters were invalid: error parsing authenticated parameter "data": no field named row_data in claims',
186187
):
187188
await tool.ainvoke({})
188189

190+
189191
@pytest.mark.usefixtures("toolbox_server")
190192
class TestE2EClientSync:
191193
@pytest.fixture(scope="session")
@@ -262,7 +264,8 @@ def test_run_tool_unauth_with_auth(self, toolbox, auth_token2):
262264
match="Validation failed for tool 'get-row-by-id': unused auth tokens: my-test-auth.",
263265
):
264266
toolbox.load_tool(
265-
"get-row-by-id", auth_token_getters={"my-test-auth": lambda: auth_token2}
267+
"get-row-by-id",
268+
auth_token_getters={"my-test-auth": lambda: auth_token2},
266269
)
267270

268271
def test_run_tool_no_auth(self, toolbox):
@@ -325,6 +328,6 @@ def test_run_tool_param_auth_no_field(self, toolbox, auth_token1):
325328
)
326329
with pytest.raises(
327330
ToolException,
328-
match="provided parameters were invalid: error parsing authenticated parameter \"data\": no field named row_data in claims",
331+
match='provided parameters were invalid: error parsing authenticated parameter "data": no field named row_data in claims',
329332
):
330333
tool.invoke({})

0 commit comments

Comments
 (0)