@@ -54,7 +54,7 @@ def __init__(
54
54
params : Sequence [Parameter ],
55
55
required_authn_params : Mapping [str , list [str ]],
56
56
auth_service_token_getters : Mapping [str , Callable [[], str ]],
57
- bound_params : Mapping [str , Union [Callable [[], Any ], Any ]] = {} ,
57
+ bound_params : Mapping [str , Union [Callable [[], Any ], Any ]],
58
58
):
59
59
"""
60
60
Initializes a callable that will trigger the tool invocation through the
@@ -71,6 +71,9 @@ def __init__(
71
71
of services that provide values for them.
72
72
auth_service_token_getters: A dict of authService -> token (or callables that
73
73
produce a token)
74
+ bound_params: A mapping of parameter names to bind to specific values or
75
+ callables that are called to produce values as needed.
76
+
74
77
"""
75
78
76
79
# used to invoke the toolbox API
@@ -92,7 +95,7 @@ def __init__(
92
95
self .__required_authn_params = required_authn_params
93
96
# map of authService -> token_getter
94
97
self .__auth_service_token_getters = auth_service_token_getters
95
- # map of parameter name to value or Callable
98
+ # map of parameter name to value ( or callable that produces that value)
96
99
self .__bound_parameters = bound_params
97
100
98
101
def __copy (
@@ -120,6 +123,8 @@ def __copy(
120
123
a auth_service_token_getter set for them yet.
121
124
auth_service_token_getters: A dict of authService -> token (or callables
122
125
that produce a token)
126
+ bound_params: A mapping of parameter names to bind to specific values or
127
+ callables that are called to produce values as needed.
123
128
124
129
"""
125
130
check = lambda val , default : val if val is not None else default
@@ -235,7 +240,7 @@ def add_auth_token_getters(
235
240
)
236
241
237
242
def bind_parameters (
238
- self , bound_params : Mapping [str , Callable [[], str ]]
243
+ self , bound_params : Mapping [str , Union [ Callable [[], Any ], Any ]]
239
244
) -> "ToolboxTool" :
240
245
"""
241
246
Binds parameters to values or callables that produce values.
@@ -247,9 +252,9 @@ def bind_parameters(
247
252
Returns:
248
253
A new ToolboxTool instance with the specified parameters bound.
249
254
"""
250
- all_params = set (p .name for p in self .__params )
255
+ param_names = set (p .name for p in self .__params )
251
256
for name in bound_params .keys ():
252
- if name not in all_params :
257
+ if name not in param_names :
253
258
raise Exception (f"unable to bind parameters: no parameter named { name } " )
254
259
255
260
new_params = []
@@ -270,11 +275,11 @@ def identify_required_authn_params(
270
275
Identifies authentication parameters that are still required; because they
271
276
not covered by the provided `auth_service_names`.
272
277
273
- Args:
274
- req_authn_params: A mapping of parameter names to sets of required
275
- authentication services.
276
- auth_service_names: An iterable of authentication service names for which
277
- token getters are available.
278
+ Args:
279
+ req_authn_params: A mapping of parameter names to sets of required
280
+ authentication services.
281
+ auth_service_names: An iterable of authentication service names for which
282
+ token getters are available.
278
283
279
284
Returns:
280
285
A new dictionary representing the subset of required authentication parameters
0 commit comments