Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 6 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.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.