inspect.getargspec is deprecated on py3

use inspect.getfullargspec instead

Change-Id: Ibdadb08b23738490646db676312bc87c3bf27eaa
This commit is contained in:
Eyal 2019-04-15 10:30:20 +03:00
parent 401eeddb2d
commit 59a96b73f1
1 changed files with 13 additions and 4 deletions

View File

@ -15,6 +15,8 @@
import inspect
import json
import six
def get_public_fields(obj):
"""Returns only public fields from object or class."""
@ -42,7 +44,7 @@ def get_docstring(obj):
def get_arg_list(func):
argspec = inspect.getargspec(func)
argspec = get_args_spec(func)
args = argspec.args
@ -57,7 +59,7 @@ def get_arg_list_as_str(func):
if args:
return args
argspec = inspect.getargspec(func)
argspec = get_args_spec(func)
defs = list(argspec.defaults or [])
args = get_arg_list(func)
@ -79,7 +81,14 @@ def get_arg_list_as_str(func):
else:
arg_str_list.append("%s" % args[index])
if argspec.keywords:
arg_str_list.append("**%s" % argspec.keywords)
keywords = argspec.keywords if six.PY2 else argspec.varkw
if keywords:
arg_str_list.append("**%s" % keywords)
return ", ".join(arg_str_list)
def get_args_spec(func):
if six.PY2:
return inspect.getargspec(func)
return inspect.getfullargspec(func)