app,command: disallow abbrev by default
By default, abbrev support is enabled in argparse, which can mangle cliff arguments as shown in the test since all the arguments from all the commands are not registered at once in the parser, but are parsed in multiple passes. It's a nasty behaviour that by default can break application using cliff without having them noticing. Since I don't think anyone is really relying on the abbrev behaviour for real, let's just disable it altogether. Depends-On: I903ce9564a83d3ee69f4efeb726d3c2d3ff69bbb Change-Id: I77127e364e938418de36b09c0b80644b77d62336
This commit is contained in:
parent
9b2ecef476
commit
1e3ef64179
|
@ -122,6 +122,7 @@ class App(object):
|
|||
parser = argparse.ArgumentParser(
|
||||
description=description,
|
||||
add_help=False,
|
||||
allow_abbrev=False,
|
||||
**argparse_kwargs
|
||||
)
|
||||
parser.add_argument(
|
||||
|
|
|
@ -34,6 +34,7 @@ class Command(object):
|
|||
parser = argparse.ArgumentParser(
|
||||
description=self.get_description(),
|
||||
prog=prog_name,
|
||||
allow_abbrev=False,
|
||||
)
|
||||
return parser
|
||||
|
||||
|
|
|
@ -264,8 +264,7 @@ def test_option_parser_abbrev_issue():
|
|||
def build_option_parser(self, description, version):
|
||||
parser = super(MyApp, self).build_option_parser(
|
||||
description,
|
||||
version,
|
||||
argparse_kwargs={'allow_abbrev': False})
|
||||
version)
|
||||
parser.add_argument('--endpoint')
|
||||
return parser
|
||||
|
||||
|
|
Loading…
Reference in New Issue