chore: Update usages of inspect getargspec

Deprecated since version 3.0: Use getfullargspec() for an updated API that is usually a drop-in replacement, but also correctly handles function annotations and keyword-only parameters.

ref: https://docs.python.org/3/library/inspect.html#inspect.getargspec
This commit is contained in:
Gavin D'souza 2021-05-05 18:31:26 +05:30
parent 3875004d7e
commit e1c69cecca
3 changed files with 6 additions and 12 deletions

View file

@ -1178,13 +1178,10 @@ def get_newargs(fn, kwargs):
if hasattr(fn, 'fnargs'):
fnargs = fn.fnargs
else:
try:
fnargs, varargs, varkw, defaults = inspect.getargspec(fn)
except ValueError:
fnargs = inspect.getfullargspec(fn).args
varargs = inspect.getfullargspec(fn).varargs
varkw = inspect.getfullargspec(fn).varkw
defaults = inspect.getfullargspec(fn).defaults
fnargs = inspect.getfullargspec(fn).args
varargs = inspect.getfullargspec(fn).varargs
varkw = inspect.getfullargspec(fn).varkw
defaults = inspect.getfullargspec(fn).defaults
newargs = {}
for a in kwargs:

View file

@ -228,10 +228,7 @@ def run_doc_method(method, docs=None, dt=None, dn=None, arg=None, args=None):
is_whitelisted(fn)
is_valid_http_method(fn)
try:
fnargs = inspect.getargspec(method_obj)[0]
except ValueError:
fnargs = inspect.getfullargspec(method_obj).args
fnargs = inspect.getfullargspec(method_obj).args
if not fnargs or (len(fnargs)==1 and fnargs[0]=="self"):
response = doc.run_method(method)

View file

@ -52,7 +52,7 @@ def update_controller_context(context, controller):
if hasattr(module, "get_context"):
import inspect
try:
if inspect.getargspec(module.get_context).args:
if inspect.getfullargspec(module.get_context).args:
ret = module.get_context(context)
else:
ret = module.get_context()