From b3e1b3ade9f073567cb057fbac419ece16fde66e Mon Sep 17 00:00:00 2001 From: Kenji Brameld Date: Fri, 29 Mar 2024 17:13:42 -0500 Subject: [PATCH] Fix regression in RHEL 8 / Python3.6 support. (#700) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check for python version to handle method signature change in argparse Signed-off-by: ijnek Co-authored-by: Steven! Ragnarök --- bloom/commands/generate.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bloom/commands/generate.py b/bloom/commands/generate.py index d93c813d..647fe8c4 100644 --- a/bloom/commands/generate.py +++ b/bloom/commands/generate.py @@ -58,13 +58,15 @@ def load_generator_description(generator_name): def create_subparsers(parser, generator_cmds): metavar = '[' + ' | '.join(generator_cmds) + ']' - subparsers = parser.add_subparsers( - title='generate commands', - metavar=metavar, - description='Call `bloom-generate {0} -h` for help on a each generate command.'.format(metavar), - dest='generator_cmd', - required=True - ) + subparsers_kwargs = { + 'title': 'generate commands', + 'metavar': metavar, + 'description': 'Call `bloom-generate {0} -h` for help on a each generate command.'.format(metavar), + 'dest': 'generator_cmd' + } + if sys.version_info >= (3, 7): + subparsers_kwargs['required'] = True + subparsers = parser.add_subparsers(**subparsers_kwargs) for generator_cmd in generator_cmds: desc = load_generator_description(generator_cmd) cmd_parser = subparsers.add_parser(desc['title'], description=desc['description'])