Replace inspect.getargspec with inspect.signature

Python 3.11 removed the long deprecated inspect.getargspec. Update
lodgeit to use inspect.signature instead. The signature api appears to
be the modern thing that is expected to work into the future.

Change-Id: Ic5603f848c0fffd15d9ce07cd7450638552c82c7
This commit is contained in:
Clark Boylan 2023-10-09 12:51:24 -07:00
parent ac772da1f6
commit fd508a8c19
1 changed files with 10 additions and 9 deletions

View File

@ -42,16 +42,17 @@ def get_public_methods():
for name, f in six.iteritems(json.funcs):
if name.startswith('system.') or f.hidden:
continue
args, varargs, varkw, defaults = inspect.getargspec(f)
if args and args[0] == 'request':
args = args[1:]
sig = inspect.signature(f)
# parameters is returned as a read only mappingproxy
params = sig.parameters.copy()
if params and list(params.keys())[0] == 'request':
# Throw out the first parameter
params.popitem(last=False)
sig = sig.replace(parameters=params.values())
result.append({
'name': name,
'doc': inspect.getdoc(f) or '',
'signature': inspect.formatargspec(
args, varargs, varkw, defaults,
formatvalue=lambda o: '=' + repr(o)
)
'name': name,
'doc': inspect.getdoc(f) or '',
'signature': str(sig)
})
result.sort(key=lambda x: x['name'].lower())
_public_methods = result