Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-99735: Handle no arguments when using sub-commands in argparse #99736

Closed
wants to merge 3 commits into from

Conversation

ppaez
Copy link
Contributor

@ppaez ppaez commented Nov 23, 2022

This provides a fix to improve the example in the documentation.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Nov 23, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@ppaez ppaez changed the title gh-58247: Handle no arguments when using sub-commands in argparse gh-99735: Handle no arguments when using sub-commands in argparse Nov 23, 2022
Comment on lines +1855 to +1858
One particularly effective way of handling sub-commands is to
combine the use of the :meth:`add_subparsers` method with calls to
:meth:`set_defaults` so that each subparser knows which Python
function it should execute. The :meth:`set_defaults` method of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend keeping the original structure so just the new changes can be more easily reviewed.

Suggested change
One particularly effective way of handling sub-commands is to
combine the use of the :meth:`add_subparsers` method with calls to
:meth:`set_defaults` so that each subparser knows which Python
function it should execute. The :meth:`set_defaults` method of the
One particularly effective way of handling sub-commands is to combine the use
of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so
that each subparser knows which Python function it should execute.
The :meth:`set_defaults` method of the

combine the use of the :meth:`add_subparsers` method with calls to
:meth:`set_defaults` so that each subparser knows which Python
function it should execute. The :meth:`set_defaults` method of the
main parser is called to handle the case when no subcommand is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nit, since 'sub-command' was used above in the same paragraph

Suggested change
main parser is called to handle the case when no subcommand is
main parser is called to handle the case when no sub-command is

@hauntsaninja
Copy link
Contributor

Thanks! Closing in favour of #100927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants