From b49aeb75b05c59ad68e5dc9202461212ef5f5748 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 28 May 2014 12:23:38 +0300 Subject: [PATCH] config: allow adding config file arg without help 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 --- gbp/config.py | 2 +- tests/doctests/test_Config.py | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gbp/config.py b/gbp/config.py index e2c863d0..9357e267 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -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) diff --git a/tests/doctests/test_Config.py b/tests/doctests/test_Config.py index 5311f947..482be249 100644 --- a/tests/doctests/test_Config.py +++ b/tests/doctests/test_Config.py @@ -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') """