diff options
author | likui <likui@yovole.com> | 2021-05-11 09:58:58 +0800 |
---|---|---|
committer | likui <likui@yovole.com> | 2021-05-13 09:12:39 +0800 |
commit | 075345196d0747168a27d71aae4e3d97c5746907 (patch) | |
tree | 18029da491205b1da99529a7ae42b3210145f144 | |
parent | fa0535a88831cb7b91c0bf9568679a21c77f9e7c (diff) | |
download | cliff-075345196d0747168a27d71aae4e3d97c5746907.tar.gz |
Replace getargspec with getfullargspec
inspect.getargspec() is deprecated since py3
[1] https://docs.python.org/3/library/inspect.html#inspect.getargspec
Change-Id: I7a1692d9979e9ffaf781de1f39f5bfa59a01cf3c
-rw-r--r-- | cliff/app.py | 3 | ||||
-rw-r--r-- | cliff/commandmanager.py | 5 | ||||
-rw-r--r-- | cliff/help.py | 5 | ||||
-rw-r--r-- | cliff/utils.py | 7 |
4 files changed, 6 insertions, 14 deletions
diff --git a/cliff/app.py b/cliff/app.py index 603778d..d185214 100644 --- a/cliff/app.py +++ b/cliff/app.py @@ -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 diff --git a/cliff/commandmanager.py b/cliff/commandmanager.py index 1787fcf..4f46014 100644 --- a/cliff/commandmanager.py +++ b/cliff/commandmanager.py @@ -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: diff --git a/cliff/help.py b/cliff/help.py index cb858fd..9ccfeb7 100644 --- a/cliff/help.py +++ b/cliff/help.py @@ -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 diff --git a/cliff/utils.py b/cliff/utils.py index cee1087..50f3ab6 100644 --- a/cliff/utils.py +++ b/cliff/utils.py @@ -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. |