-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
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
Description
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
scalisi
Metadata
Metadata
Assignees
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
Projects
Status
Doc issues