summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-06-01 19:33:28 +0000
committerGerrit Code Review <review@openstack.org>2021-06-01 19:33:28 +0000
commit84cfbddf349b27d2c563e5b16857dcfce3e756b3 (patch)
treee1ec949991433ccf322d10c2d7c7dde65f8517cf /nova
parentda57eebc9e1ab7e48d4c4ef6ec1eeba80d867d81 (diff)
parent150b9182512fa0a4f157586e040a7f67c1851005 (diff)
downloadnova-84cfbddf349b27d2c563e5b16857dcfce3e756b3.tar.gz
Merge "Replace getargspec with getfullargspec"
Diffstat (limited to 'nova')
-rw-r--r--nova/cmd/common.py4
-rw-r--r--nova/network/neutron.py3
-rw-r--r--nova/test.py6
-rw-r--r--nova/tests/unit/objects/test_objects.py5
-rw-r--r--nova/tests/unit/virt/libvirt/test_imagebackend.py8
-rw-r--r--nova/utils.py8
6 files changed, 16 insertions, 18 deletions
diff --git a/nova/cmd/common.py b/nova/cmd/common.py
index c3f62fa57e..1d4d5b4612 100644
--- a/nova/cmd/common.py
+++ b/nova/cmd/common.py
@@ -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]
diff --git a/nova/network/neutron.py b/nova/network/neutron.py
index 9c3186b525..7db03a41ee 100644
--- a/nova/network/neutron.py
+++ b/nova/network/neutron.py
@@ -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):
diff --git a/nova/test.py b/nova/test.py
index 8b3facbab7..4fd6c479de 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -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
diff --git a/nova/tests/unit/objects/test_objects.py b/nova/tests/unit/objects/test_objects.py
index b2f4f0616d..13d3270894 100644
--- a/nova/tests/unit/objects/test_objects.py
+++ b/nova/tests/unit/objects/test_objects.py
@@ -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):
diff --git a/nova/tests/unit/virt/libvirt/test_imagebackend.py b/nova/tests/unit/virt/libvirt/test_imagebackend.py
index 2acd7e0aff..e9f2707f73 100644
--- a/nova/tests/unit/virt/libvirt/test_imagebackend.py
+++ b/nova/tests/unit/virt/libvirt/test_imagebackend.py
@@ -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):
diff --git a/nova/utils.py b/nova/utils.py
index 5239dd4ba8..c1b4fccc47 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -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