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

argparse incorrectly says arguments are required #103219

Copy link
Copy link
@eslindsey

Description

@eslindsey
Issue body actions

When using nargs='*' with other required arguments, argparse incorrectly says the optional argument is required.

Output (with no arguments)

usage: example [-h] foo [bar ...]
example: error: the following arguments are required: foo, bar

Code

import argparse

parser = argparse.ArgumentParser(prog='example')
parser.add_argument('foo')
parser.add_argument('bar', nargs='*')
args = parser.parse_args()

Python 3.9.16

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    Status
    Doc issues
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.