Skip to content

Commit

Permalink
Fix bug in accepts_list_and_has_nargs section.
Browse files Browse the repository at this point in the history
  • Loading branch information
bw2 authored Apr 23, 2020
1 parent 6b34e07 commit 705af2e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions configargparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,11 @@ def convert_item_to_command_line_arg(self, action, key, value):
self.error("Unexpected value for %s: '%s'. Expecting 'true', "
"'false', 'yes', 'no', '1' or '0'" % (key, value))
elif isinstance(value, list):
accepts_list = ((isinstance(action, argparse._StoreAction) or
isinstance(action, argparse._AppendAction)) and
action.nargs is not None and (
action.nargs in ('+', '*')) or
(isinstance(action.nargs, int) and action.nargs > 1))
accepts_list_and_has_nargs = action is not None and action.nargs is not None and (
isinstance(action, argparse._StoreAction) or isinstance(action, argparse._AppendAction)
) and (
action.nargs in ('+', '*') or (isinstance(action.nargs, int) and action.nargs > 1)
)

if action is None or isinstance(action, argparse._AppendAction):
for list_elem in value:
Expand All @@ -755,7 +755,7 @@ def convert_item_to_command_line_arg(self, action, key, value):
args.append(str(sub_elem))
else:
args.append( "%s=%s" % (command_line_key, str(list_elem)) )
elif accepts_list:
elif accepts_list_and_has_nargs:
args.append( command_line_key )
for list_elem in value:
args.append( str(list_elem) )
Expand Down

0 comments on commit 705af2e

Please sign in to comment.