Ensure python standard argparse module is loaded
When 'import argparse' is used in cliff.something module, cliff.argparse is loaded instead of python standard argparse. This causes cliff.sphinxext failure with no attribute _HelpAction. This can be avoided by renaming cliff.argparse to non-overlapping module name like _argparse. cliff.argparse is for internal use, so I believe it is safe to rename the module. Closes-Bug: #1692018 Change-Id: Ic34f61581316c662dd2d672bc2c088dcef2100a9
This commit is contained in:
parent
c548b7b44c
commit
f2c381c708
|
@ -22,7 +22,7 @@ import os
|
|||
import six
|
||||
import sys
|
||||
|
||||
from cliff import argparse
|
||||
from cliff import _argparse
|
||||
from . import complete
|
||||
from . import help
|
||||
from . import utils
|
||||
|
@ -143,7 +143,7 @@ class App(object):
|
|||
:paramtype extra_kwargs: dict
|
||||
"""
|
||||
argparse_kwargs = argparse_kwargs or {}
|
||||
parser = argparse.ArgumentParser(
|
||||
parser = _argparse.ArgumentParser(
|
||||
description=description,
|
||||
add_help=False,
|
||||
**argparse_kwargs
|
||||
|
|
|
@ -15,7 +15,7 @@ import inspect
|
|||
|
||||
import six
|
||||
|
||||
from cliff import argparse
|
||||
from cliff import _argparse
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
|
@ -67,7 +67,7 @@ class Command(object):
|
|||
def get_parser(self, prog_name):
|
||||
"""Return an :class:`argparse.ArgumentParser`.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
parser = _argparse.ArgumentParser(
|
||||
description=self.get_description(),
|
||||
epilog=self.get_epilog(),
|
||||
prog=prog_name,
|
||||
|
@ -97,7 +97,7 @@ class Command(object):
|
|||
return self.take_action(parsed_args) or 0
|
||||
|
||||
|
||||
class _SmartHelpFormatter(argparse.HelpFormatter):
|
||||
class _SmartHelpFormatter(_argparse.HelpFormatter):
|
||||
"""Smart help formatter to output raw help message if help contain \n.
|
||||
|
||||
Some command help messages maybe have multiple line content, the built-in
|
||||
|
|
Loading…
Reference in New Issue