Replace getargspec with getfullargspec

inspect.getargspec() is deprecated since py3

[1] https://docs.python.org/3/library/inspect.html#inspect.getargspec

Change-Id: I7a1692d9979e9ffaf781de1f39f5bfa59a01cf3c
This commit is contained in:
likui 2021-05-11 09:58:58 +08:00
parent fa0535a888
commit 075345196d
4 changed files with 6 additions and 14 deletions

View File

@ -13,6 +13,7 @@
"""Application base class.
"""
import inspect
import locale
import logging
import logging.handlers
@ -382,7 +383,7 @@ class App(object):
return 2
cmd_factory, cmd_name, sub_argv = subcommand
kwargs = {}
if 'cmd_name' in utils.getargspec(cmd_factory.__init__).args:
if 'cmd_name' in inspect.getfullargspec(cmd_factory.__init__).args:
kwargs['cmd_name'] = cmd_name
cmd = cmd_factory(self, self.options, **kwargs)
result = 1

View File

@ -13,12 +13,11 @@
"""Discover and lookup command plugins.
"""
import inspect
import logging
import stevedore
from . import utils
LOG = logging.getLogger(__name__)
@ -125,7 +124,7 @@ class CommandManager(object):
else:
# NOTE(dhellmann): Some fake classes don't take
# require as an argument. Yay?
arg_spec = utils.getargspec(cmd_ep.load)
arg_spec = inspect.getfullargspec(cmd_ep.load)
if 'require' in arg_spec[0]:
cmd_factory = cmd_ep.load(require=False)
else:

View File

@ -15,7 +15,6 @@ import inspect
import traceback
from . import command
from . import utils
class HelpExit(SystemExit):
@ -58,7 +57,7 @@ class HelpAction(argparse.Action):
continue
try:
kwargs = {}
if 'cmd_name' in utils.getargspec(factory.__init__).args:
if 'cmd_name' in inspect.getfullargspec(factory.__init__).args:
kwargs['cmd_name'] = name
cmd = factory(app, None, **kwargs)
if cmd.deprecated:
@ -111,7 +110,7 @@ class HelpCommand(command.Command):
return
self.app_args.cmd = search_args
kwargs = {}
if 'cmd_name' in utils.getargspec(cmd_factory.__init__).args:
if 'cmd_name' in inspect.getfullargspec(cmd_factory.__init__).args:
kwargs['cmd_name'] = cmd_name
cmd = cmd_factory(self.app, self.app_args, **kwargs)
full_name = (cmd_name

View File

@ -12,7 +12,6 @@
# limitations under the License.
import ctypes
import inspect
import os
import struct
import sys
@ -26,12 +25,6 @@ import sys
COST = {'w': 0, 's': 2, 'a': 1, 'd': 3}
if hasattr(inspect, 'getfullargspec'):
getargspec = inspect.getfullargspec
else:
getargspec = inspect.getargspec
def damerau_levenshtein(s1, s2, cost):
"""Calculates the Damerau-Levenshtein distance between two strings.