Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ def _get_positional_kwargs(self, dest, **kwargs):

# mark positional arguments as required if at least one is
# always required
if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]:
if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE, REMAINDER]:
kwargs['required'] = True
if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs:
kwargs['required'] = True
Expand Down Expand Up @@ -1915,6 +1915,10 @@ def take_action(action, argument_strings, option_string=None):
# error if this argument is not allowed with other previously
# seen arguments, assuming that actions that use the default
# value don't really count as "present"
if action.nargs in [REMAINDER]:
if argument_values == []:
action.default = argument_values

if argument_values is not action.default:
seen_non_default_actions.add(action)
for conflict_action in action_conflicts.get(action, []):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow REMAINDER positional arguments in argparse mutually exclusive groups.