Skip to content

Commit 84cfbdd

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Replace getargspec with getfullargspec"
2 parents da57eeb + 150b918 commit 84cfbdd

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed

nova/cmd/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919

2020
import argparse
21+
import inspect
2122
import traceback
2223

2324
from oslo_log import log as logging
@@ -26,7 +27,6 @@
2627
import nova.db.api
2728
from nova import exception
2829
from nova.i18n import _
29-
from nova import utils
3030

3131
CONF = nova.conf.CONF
3232
LOG = logging.getLogger(__name__)
@@ -65,7 +65,7 @@ def validate_args(fn, *args, **kwargs):
6565
:param arg: the positional arguments supplied
6666
:param kwargs: the keyword arguments supplied
6767
"""
68-
argspec = utils.getargspec(fn)
68+
argspec = inspect.getfullargspec(fn)
6969

7070
num_defaults = len(argspec.defaults or [])
7171
required_args = argspec.args[:len(argspec.args) - num_defaults]

nova/network/neutron.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import copy
2222
import functools
23+
import inspect
2324
import time
2425
import typing as ty
2526

@@ -133,7 +134,7 @@ def refresh_cache(f):
133134
134135
Requires context and instance as function args
135136
"""
136-
argspec = utils.getargspec(f)
137+
argspec = inspect.getfullargspec(f)
137138

138139
@functools.wraps(f)
139140
def wrapper(self, context, *args, **kwargs):

nova/test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,8 @@ def findmethods(object):
633633

634634
for name in sorted(implmethods.keys()):
635635
# NOTE(stephenfin): We ignore type annotations
636-
baseargs = utils.getargspec(basemethods[name])[:-1]
637-
implargs = utils.getargspec(implmethods[name])[:-1]
636+
baseargs = inspect.getfullargspec(basemethods[name])[:-1]
637+
implargs = inspect.getfullargspec(implmethods[name])[:-1]
638638

639639
self.assertEqual(baseargs, implargs,
640640
"%s args don't match base class %s" %
@@ -707,7 +707,7 @@ def _get_argspecs(cls):
707707
# instead.
708708
method = getattr(method, '__wrapped__')
709709

710-
argspecs[name] = utils.getargspec(method)
710+
argspecs[name] = inspect.getfullargspec(method)
711711

712712
return argspecs
713713

nova/tests/unit/objects/test_objects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import contextlib
1717
import copy
1818
import datetime
19+
import inspect
1920
import os
2021
import pprint
2122

@@ -1318,12 +1319,12 @@ def test_object_ignore_equal(self):
13181319

13191320
class TestObjMethodOverrides(test.NoDBTestCase):
13201321
def test_obj_reset_changes(self):
1321-
args = utils.getargspec(base.NovaObject.obj_reset_changes)
1322+
args = inspect.getfullargspec(base.NovaObject.obj_reset_changes)
13221323
obj_classes = base.NovaObjectRegistry.obj_classes()
13231324
for obj_name in obj_classes:
13241325
obj_class = obj_classes[obj_name][0]
13251326
self.assertEqual(args,
1326-
utils.getargspec(obj_class.obj_reset_changes))
1327+
inspect.getfullargspec(obj_class.obj_reset_changes))
13271328

13281329

13291330
class TestObjectsDefaultingOnInit(test.NoDBTestCase):

nova/tests/unit/virt/libvirt/test_imagebackend.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import base64
1717
import errno
18+
import inspect
1819
import os
1920
import shutil
2021
import tempfile
@@ -38,7 +39,6 @@
3839
from nova.storage import rbd_utils
3940
from nova import test
4041
from nova.tests.unit import fake_processutils
41-
from nova import utils
4242
from nova.virt.image import model as imgmodel
4343
from nova.virt import images
4444
from nova.virt.libvirt import config as vconfig
@@ -1488,8 +1488,10 @@ def fake_fetch(target, *args, **kwargs):
14881488
self.assertEqual(fake_processutils.fake_execute_get_log(), [])
14891489

14901490
def test_parent_compatible(self):
1491-
self.assertEqual(utils.getargspec(imagebackend.Image.libvirt_info),
1492-
utils.getargspec(self.image_class.libvirt_info))
1491+
self.assertEqual(
1492+
inspect.getfullargspec(imagebackend.Image.libvirt_info),
1493+
inspect.getfullargspec(self.image_class.libvirt_info)
1494+
)
14931495

14941496
def test_image_path(self):
14951497

nova/utils.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@
8080
_SERVICE_TYPES = service_types.ServiceTypes()
8181

8282

83-
if hasattr(inspect, 'getfullargspec'):
84-
getargspec = inspect.getfullargspec
85-
else:
86-
getargspec = inspect.getargspec
87-
88-
8983
# NOTE(mikal): this seems to have to stay for now to handle os-brick
9084
# requirements. This makes me a sad panda.
9185
def get_root_helper():
@@ -553,7 +547,7 @@ def _decorator_checker(dec):
553547
@functools.wraps(dec)
554548
def _decorator(f):
555549
base_f = safe_utils.get_wrapped_function(f)
556-
argspec = getargspec(base_f)
550+
argspec = inspect.getfullargspec(base_f)
557551
if argspec[1] or argspec[2] or set(args) <= set(argspec[0]):
558552
# NOTE (ndipanov): We can't really tell if correct stuff will
559553
# be passed if it's a function with *args or **kwargs so

0 commit comments

Comments
 (0)