MCPcopy Index your code
hub / github.com/google/adk-python / _get_mandatory_args

Method _get_mandatory_args

src/google/adk/tools/function_tool.py:328–351  ·  view source on GitHub ↗

Identifies mandatory parameters (those without default values) for a function. Returns: A list of strings, where each string is the name of a mandatory parameter.

(
      self,
  )

Source from the content-addressed store, hash-verified

326 yield item
327
328 def _get_mandatory_args(
329 self,
330 ) -> list[str]:
331 """Identifies mandatory parameters (those without default values) for a function.
332
333 Returns:
334 A list of strings, where each string is the name of a mandatory parameter.
335 """
336 signature = inspect.signature(self.func)
337 mandatory_params = []
338
339 for name, param in signature.parameters.items():
340 # A parameter is mandatory if:
341 # 1. It has no default value (param.default is inspect.Parameter.empty)
342 # 2. It's not a variable positional (*args) or variable keyword (**kwargs) parameter
343 #
344 # For more refer to: https://docs.python.org/3/library/inspect.html#inspect.Parameter.kind
345 if param.default == inspect.Parameter.empty and param.kind not in (
346 inspect.Parameter.VAR_POSITIONAL,
347 inspect.Parameter.VAR_KEYWORD,
348 ):
349 mandatory_params.append(name)
350
351 return mandatory_params

Callers 3

run_asyncMethod · 0.95
run_asyncMethod · 0.80

Calls 2

itemsMethod · 0.45
appendMethod · 0.45

Tested by 1