diff --git a/volttron/platform/vip/agent/subsystems/rpc.py b/volttron/platform/vip/agent/subsystems/rpc.py index 7945f2dc4c..441b59b745 100644 --- a/volttron/platform/vip/agent/subsystems/rpc.py +++ b/volttron/platform/vip/agent/subsystems/rpc.py @@ -168,11 +168,18 @@ def method(self, request, ident, name, args, kwargs, del local.request del local.batch - def _inspect(self, method): - params = inspect.getargspec(method) - if hasattr(method, 'im_self'): - params.args.pop(0) - response = {'params': params} + @staticmethod + def _inspect(method): + response = {'params': {}} + signature = inspect.signature(method) + for p in signature.parameters.values(): + response['params'][p.name] = { + 'kind': p.kind.description + } + if p.default is not inspect.Parameter.empty: + response['params'][p.name]['default'] = p.default + if p.annotation is not inspect.Parameter.empty: + response['params'][p.name]['annotation'] = p.annotation doc = inspect.getdoc(method) if doc: response['doc'] = doc @@ -181,15 +188,15 @@ def _inspect(self, method): cut = len(os.path.commonprefix([_ROOT_PACKAGE_PATH, source])) source = source[cut:] lineno = inspect.getsourcelines(method)[1] - except IOError: + except Exception: pass else: - response['source'] = source, lineno - try: - # pylint: disable=protected-access - response['return'] = method._returns - except AttributeError: - pass + response['source'] = { + 'file': source, + 'line_number': lineno + } + if signature.return_annotation is not inspect.Signature.empty: + response['return'] = signature.return_annotation return response