Takes named function parameters and returns a list of those needed, in the order they should appear
(self, func_name: str, args: Any, **kwargs: Any)
| 222 | raise TypeError(f"Unsupported type: {type(arg)}") |
| 223 | |
| 224 | def _convert_func_named_args(self, func_name: str, args: Any, **kwargs: Any) -> Any: |
| 225 | """ |
| 226 | Takes named function parameters and returns a list of those needed, |
| 227 | in the order they should appear |
| 228 | """ |
| 229 | # kwargs can be a super set of the required function parameters. |
| 230 | # We only find the ones that are needed. |
| 231 | func_arity = self._get_function_arity(func_name) |
| 232 | func_params = [self._get_function_param_name(func_name, i) for i in range(func_arity)] |
| 233 | new_args = [None] * len(func_params) |
| 234 | cnt = 0 |
| 235 | for k in kwargs: |
| 236 | if k in func_params: |
| 237 | idx = func_params.index(k) |
| 238 | new_args[idx] = kwargs[k] |
| 239 | cnt += 1 |
| 240 | else: |
| 241 | print(f'Warning: Keyword argument "{k}" is unused in {func_name}') |
| 242 | assert len(args) + cnt == len(func_params) |
| 243 | idx = 0 |
| 244 | for i, arg in enumerate(new_args): |
| 245 | if arg is None: |
| 246 | new_args[i] = args[idx] |
| 247 | idx += 1 |
| 248 | return new_args |
| 249 | |
| 250 | def set_input(self, func_name: str, *args: Any, **kwargs: Any) -> None: |
| 251 | """Set the inputs to a function. |
no test coverage detected