Skip to content

Commit

Permalink
config: allow adding config file arg without help
Browse files Browse the repository at this point in the history
Previously, adding a config file arg with no help resulted in KeyError
if no default help text was defined. Now, it is possible to add a config
arg without a help text. This makes the argument parser more consistent
as adding "non-conf-file-args" requires no help text, either.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
  • Loading branch information
marquiz committed Jan 18, 2018
1 parent 4ef5a20 commit b49aeb7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion gbp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def add_conf_file_arg(self, *args, **kwargs):
else:
kwargs['default'] = self.config.get_value(name)
self.conf_file_args.add(name)
if 'help' not in kwargs:
if 'help' not in kwargs and name in self.config.default_helps:
kwargs['help'] = self.config.default_helps[name]
new_arg = self.add_arg(*args, **kwargs)

Expand Down
4 changes: 0 additions & 4 deletions tests/doctests/test_Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ def test_option_parser_debian():
>>> import gbp.config
>>> c = gbp.config.GbpConfArgParserDebian.create_parser(prog='debian')
>>> c.add_conf_file_arg('--builder', dest='builder')
Traceback (most recent call last):
...
KeyError: 'builder'
>>> c.add_conf_file_arg('--builder', dest='builder', help='foo')
"""

Expand Down

0 comments on commit b49aeb7

Please sign in to comment.