Skip to content

Incorrect information in add_subparser() docs.  #95377

Description

@JCrane512

Documentation

When setting the flag required=true for the function ArgumentParser.add_subparsers() the setting dest=" some description" also needs to be set or the parser throws an unhelpful error when the user fails to select a subparser.

This is not covered in the documentation.

Linked PRs

Activity

  1. MonadChains commented on Jul 28, 2022

    @MonadChains
    Contributor

    I agree. The documentation is not fully clear, and adding a line to clarify it could be beneficial, especially given the complexity of the module.

  2. added a commit that references this issue on Dec 24, 2022
  3. StanFromIreland commented on Aug 20, 2026

    @StanFromIreland
    Member
  4. savannahostrowski commented on Aug 21, 2026

    @savannahostrowski
    Member

    It’s unclear which Python version this was originally reported against. The underlying problem was fixed in #3680 and backported to Python 3.9 and 3.10. When no subparser is selected, argparse tells the user that one is required: error: the following arguments are required: {foo,bar}

    It does not reproduce on any branch in the current support window so I think this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

docsDocumentation in the Doc dir

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions