Skip to content

Commit 5402496

Browse files
committed
docs: Fix and improve docstrings
1 parent f2d7c9d commit 5402496

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,20 @@ 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
147147
callables that return the corresponding authentication token.
148148
149149
Returns:
150-
A new ToolboxSyncTool instance with the specified authentication token
151-
getters registered.
150+
A new ToolboxSyncTool instance with the specified authentication
151+
token getters registered.
152+
153+
Raises:
154+
ValueError: If an auth source has already been registered either to
155+
the tool or to the corresponding client.
152156
"""
153157

154158
new_async_tool = self.__async_tool.add_auth_token_getters(auth_token_getters)
@@ -158,7 +162,7 @@ def add_auth_token_getter(
158162
self, auth_source: str, get_id_token: Callable[[], str]
159163
) -> "ToolboxSyncTool":
160164
"""
161-
Registers auth token getter functions that are used for AuthServices
165+
Registers an auth token getter function that is used for AuthService
162166
when tools are invoked.
163167
164168
Args:
@@ -167,7 +171,7 @@ def add_auth_token_getter(
167171
168172
Returns:
169173
A new ToolboxSyncTool instance with the specified authentication
170-
token getters registered.
174+
token getter registered.
171175
172176
Raises:
173177
ValueError: If the auth source has already been registered either to
@@ -188,6 +192,11 @@ def bind_params(
188192
189193
Returns:
190194
A new ToolboxSyncTool instance with the specified parameters bound.
195+
196+
Raises:
197+
ValueError: If a parameter is already bound or is not defined by the
198+
tool's definition.
199+
191200
"""
192201

193202
new_async_tool = self.__async_tool.bind_params(bound_params)
@@ -199,7 +208,7 @@ def bind_param(
199208
param_value: Union[Callable[[], Any], Any],
200209
) -> "ToolboxSyncTool":
201210
"""
202-
Binds a parameter to the value or callables that produce it.
211+
Binds a parameter to the value or callable that produce the value.
203212
204213
Args:
205214
param_name: The name of the bound parameter.
@@ -208,5 +217,10 @@ def bind_param(
208217
209218
Returns:
210219
A new ToolboxSyncTool instance with the specified parameter bound.
220+
221+
Raises:
222+
ValueError: If the parameter is already bound or is not defined by
223+
the tool's definition.
224+
211225
"""
212226
return self.bind_params({param_name: param_value})

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

Lines changed: 22 additions & 12 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
@@ -292,9 +292,9 @@ def add_auth_token_getters(
292292
A new ToolboxTool instance with the specified authentication token
293293
getters registered.
294294
295-
Raises
296-
ValueError: If the auth source has already been registered either
297-
to the tool or to the corresponding client.
295+
Raises:
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
@@ -350,7 +350,7 @@ def add_auth_token_getter(
350350
self, auth_source: str, get_id_token: Callable[[], str]
351351
) -> "ToolboxTool":
352352
"""
353-
Registers auth token getter functions that are used for AuthServices
353+
Registers an auth token getter function that is used for AuthServices
354354
when tools are invoked.
355355
356356
Args:
@@ -359,11 +359,11 @@ def add_auth_token_getter(
359359
360360
Returns:
361361
A new ToolboxTool instance with the specified authentication token
362-
getters registered.
362+
getter registered.
363363
364-
Raises
365-
ValueError: If the auth source has already been registered either
366-
to the tool or to the corresponding client.
364+
Raises:
365+
ValueError: If the auth source has already been registered either to
366+
the tool or to the corresponding client.
367367
368368
"""
369369
return self.add_auth_token_getters({auth_source: get_id_token})
@@ -380,6 +380,11 @@ def bind_params(
380380
381381
Returns:
382382
A new ToolboxTool instance with the specified parameters bound.
383+
384+
Raises:
385+
ValueError: If a parameter is already bound or is not defined by the
386+
tool's definition.
387+
383388
"""
384389
param_names = set(p.name for p in self.__params)
385390
for name in bound_params.keys():
@@ -411,14 +416,19 @@ def bind_param(
411416
param_value: Union[Callable[[], Any], Any],
412417
) -> "ToolboxTool":
413418
"""
414-
Binds a parameter to the value or callables that produce it.
419+
Binds a parameter to the value or callable that produce the value.
415420
416421
Args:
417422
param_name: The name of the bound parameter.
418423
param_value: The value of the bound parameter, or a callable that
419424
returns the value.
420425
421426
Returns:
422-
A new ToolboxTool instance with the specified parameters bound.
427+
A new ToolboxTool instance with the specified parameter bound.
428+
429+
Raises:
430+
ValueError: If the parameter is already bound or is not defined by
431+
the tool's definition.
432+
423433
"""
424434
return self.bind_params({param_name: param_value})

0 commit comments

Comments
 (0)