Skip to content

Commit 1fffede

Browse files
committed
docs: Improve function docstrings in tool classes
1 parent f2d7c9d commit 1fffede

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

packages/toolbox-core/src/toolbox_core/sync_tool.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def add_auth_token_getters(
139139
auth_token_getters: Mapping[str, Callable[[], str]],
140140
) -> "ToolboxSyncTool":
141141
"""
142-
Registers an auth token getter function that is used for AuthServices when tools
143-
are invoked.
142+
Registers auth token getter functions that are used for AuthServices
143+
when tools are invoked.
144144
145145
Args:
146146
auth_token_getters: A mapping of authentication service names to
@@ -149,8 +149,12 @@ def add_auth_token_getters(
149149
Returns:
150150
A new ToolboxSyncTool instance with the specified authentication token
151151
getters registered.
152-
"""
153152
153+
Raises:
154+
ValueError: If an auth source has already been registered either to
155+
the tool or to the corresponding client.
156+
157+
"""
154158
new_async_tool = self.__async_tool.add_auth_token_getters(auth_token_getters)
155159
return ToolboxSyncTool(new_async_tool, self.__loop, self.__thread)
156160

@@ -183,13 +187,17 @@ def bind_params(
183187
Binds parameters to values or callables that produce values.
184188
185189
Args:
186-
bound_params: A mapping of parameter names to values or callables that
187-
produce values.
190+
bound_params: A mapping of parameter names to values or callables
191+
that produce values.
188192
189193
Returns:
190194
A new ToolboxSyncTool instance with the specified parameters bound.
191-
"""
192195
196+
Raises:
197+
ValueError: If a parameter has already been bound or is not present
198+
in the tool schema.
199+
200+
"""
193201
new_async_tool = self.__async_tool.bind_params(bound_params)
194202
return ToolboxSyncTool(new_async_tool, self.__loop, self.__thread)
195203

@@ -208,5 +216,9 @@ def bind_param(
208216
209217
Returns:
210218
A new ToolboxSyncTool instance with the specified parameter bound.
219+
220+
Raises:
221+
ValueError: If the parameter has already been bound or is not
222+
present in the tool schema.
211223
"""
212224
return self.bind_params({param_name: param_value})

packages/toolbox-core/src/toolbox_core/tool.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ def add_auth_token_getters(
281281
auth_token_getters: Mapping[str, Callable[[], str]],
282282
) -> "ToolboxTool":
283283
"""
284-
Registers an auth token getter function that is used for AuthServices when tools
285-
are invoked.
284+
Registers auth token getter functions that are used for AuthServices
285+
when tools are invoked.
286286
287287
Args:
288288
auth_token_getters: A mapping of authentication service names to
@@ -293,8 +293,8 @@ def add_auth_token_getters(
293293
getters registered.
294294
295295
Raises
296-
ValueError: If the auth source has already been registered either
297-
to the tool or to the corresponding client.
296+
ValueError: If an auth source has already been registered either to
297+
the tool or to the corresponding client.
298298
"""
299299

300300
# throw an error if the authentication source is already registered
@@ -380,6 +380,10 @@ def bind_params(
380380
381381
Returns:
382382
A new ToolboxTool instance with the specified parameters bound.
383+
384+
Raises:
385+
ValueError: If a parameter has already been bound or is not
386+
present in the tool schema.
383387
"""
384388
param_names = set(p.name for p in self.__params)
385389
for name in bound_params.keys():
@@ -420,5 +424,10 @@ def bind_param(
420424
421425
Returns:
422426
A new ToolboxTool instance with the specified parameters bound.
427+
428+
Raises:
429+
ValueError: If the parameter has already been bound or is not
430+
present in the tool schema.
431+
423432
"""
424433
return self.bind_params({param_name: param_value})

0 commit comments

Comments
 (0)