MCPcopy
hub / github.com/pydata/xarray / _get_func_args

Function _get_func_args

xarray/core/utils.py:1403–1425  ·  view source on GitHub ↗

Use `inspect.signature` to try accessing `func` args. Otherwise, ensure they are provided by user.

(func, param_names)

Source from the content-addressed store, hash-verified

1401
1402
1403def _get_func_args(func, param_names):
1404 """Use `inspect.signature` to try accessing `func` args. Otherwise, ensure
1405 they are provided by user.
1406 """
1407 try:
1408 func_args = inspect.signature(func).parameters
1409 except ValueError as err:
1410 func_args = {}
1411 if not param_names:
1412 raise ValueError(
1413 "Unable to inspect `func` signature, and `param_names` was not provided."
1414 ) from err
1415 if param_names:
1416 params = param_names
1417 else:
1418 params = list(func_args)[1:]
1419 if any(
1420 (p.kind in [p.VAR_POSITIONAL, p.VAR_KEYWORD]) for p in func_args.values()
1421 ):
1422 raise ValueError(
1423 "`param_names` must be provided because `func` takes variable length arguments."
1424 )
1425 return params, func_args

Callers

nothing calls this directly

Calls 1

valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…