Merge "Replace getargspec with getfullargspec"

This commit is contained in:
Zuul 2021-06-01 19:33:28 +00:00 committed by Gerrit Code Review
commit 84cfbddf34
6 changed files with 16 additions and 18 deletions

View File

@ -18,6 +18,7 @@
"""
import argparse
import inspect
import traceback
from oslo_log import log as logging
@ -26,7 +27,6 @@ import nova.conf
import nova.db.api
from nova import exception
from nova.i18n import _
from nova import utils
CONF = nova.conf.CONF
LOG = logging.getLogger(__name__)
@ -65,7 +65,7 @@ def validate_args(fn, *args, **kwargs):
:param arg: the positional arguments supplied
:param kwargs: the keyword arguments supplied
"""
argspec = utils.getargspec(fn)
argspec = inspect.getfullargspec(fn)
num_defaults = len(argspec.defaults or [])
required_args = argspec.args[:len(argspec.args) - num_defaults]

View File

@ -20,6 +20,7 @@ API and utilities for nova-network interactions.
import copy
import functools
import inspect
import time
import typing as ty
@ -133,7 +134,7 @@ def refresh_cache(f):
Requires context and instance as function args
"""
argspec = utils.getargspec(f)
argspec = inspect.getfullargspec(f)
@functools.wraps(f)
def wrapper(self, context, *args, **kwargs):

View File

@ -633,8 +633,8 @@ class TestCase(base.BaseTestCase):
for name in sorted(implmethods.keys()):
# NOTE(stephenfin): We ignore type annotations
baseargs = utils.getargspec(basemethods[name])[:-1]
implargs = utils.getargspec(implmethods[name])[:-1]
baseargs = inspect.getfullargspec(basemethods[name])[:-1]
implargs = inspect.getfullargspec(implmethods[name])[:-1]
self.assertEqual(baseargs, implargs,
"%s args don't match base class %s" %
@ -707,7 +707,7 @@ class SubclassSignatureTestCase(testtools.TestCase, metaclass=abc.ABCMeta):
# instead.
method = getattr(method, '__wrapped__')
argspecs[name] = utils.getargspec(method)
argspecs[name] = inspect.getfullargspec(method)
return argspecs

View File

@ -16,6 +16,7 @@ import collections
import contextlib
import copy
import datetime
import inspect
import os
import pprint
@ -1318,12 +1319,12 @@ class TestObjEqualPrims(_BaseTestCase):
class TestObjMethodOverrides(test.NoDBTestCase):
def test_obj_reset_changes(self):
args = utils.getargspec(base.NovaObject.obj_reset_changes)
args = inspect.getfullargspec(base.NovaObject.obj_reset_changes)
obj_classes = base.NovaObjectRegistry.obj_classes()
for obj_name in obj_classes:
obj_class = obj_classes[obj_name][0]
self.assertEqual(args,
utils.getargspec(obj_class.obj_reset_changes))
inspect.getfullargspec(obj_class.obj_reset_changes))
class TestObjectsDefaultingOnInit(test.NoDBTestCase):

View File

@ -15,6 +15,7 @@
import base64
import errno
import inspect
import os
import shutil
import tempfile
@ -38,7 +39,6 @@ from nova import objects
from nova.storage import rbd_utils
from nova import test
from nova.tests.unit import fake_processutils
from nova import utils
from nova.virt.image import model as imgmodel
from nova.virt import images
from nova.virt.libvirt import config as vconfig
@ -1488,8 +1488,10 @@ class RbdTestCase(_ImageTestCase, test.NoDBTestCase):
self.assertEqual(fake_processutils.fake_execute_get_log(), [])
def test_parent_compatible(self):
self.assertEqual(utils.getargspec(imagebackend.Image.libvirt_info),
utils.getargspec(self.image_class.libvirt_info))
self.assertEqual(
inspect.getfullargspec(imagebackend.Image.libvirt_info),
inspect.getfullargspec(self.image_class.libvirt_info)
)
def test_image_path(self):

View File

@ -80,12 +80,6 @@ _FILE_CACHE = {}
_SERVICE_TYPES = service_types.ServiceTypes()
if hasattr(inspect, 'getfullargspec'):
getargspec = inspect.getfullargspec
else:
getargspec = inspect.getargspec
# NOTE(mikal): this seems to have to stay for now to handle os-brick
# requirements. This makes me a sad panda.
def get_root_helper():
@ -553,7 +547,7 @@ def expects_func_args(*args):
@functools.wraps(dec)
def _decorator(f):
base_f = safe_utils.get_wrapped_function(f)
argspec = getargspec(base_f)
argspec = inspect.getfullargspec(base_f)
if argspec[1] or argspec[2] or set(args) <= set(argspec[0]):
# NOTE (ndipanov): We can't really tell if correct stuff will
# be passed if it's a function with *args or **kwargs so