gh-135227: argparse: Use `help` as default `description` in `add_parser` by Sonu0305 · Pull Request #135236 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

gh-135227: argparse: Use help as default description in add_parser #135236

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Sonu0305
Copy link

@Sonu0305 Sonu0305 commented Jun 7, 2025

@python-cla-bot
Copy link

python-cla-bot bot commented Jun 7, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jun 7, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

This will need a blurb entry and test for the new behavior.

@Sonu0305
Copy link
Author

Sonu0305 commented Jun 7, 2025

This will need a blurb entry and test for the new behavior.

Thanks.

edit: typo

@Sonu0305 Sonu0305 requested a review from StanFromIreland June 7, 2025 16:05
@Sonu0305 Sonu0305 force-pushed the fix_parser branch 2 times, most recently from f340e36 to 904c5be Compare June 8, 2025 13:23
@Sonu0305 Sonu0305 requested a review from brianschubert June 8, 2025 13:29
@StanFromIreland
Copy link
Member

Please stop repeatedly force pushing, it confuses GitHub.

@Sonu0305
Copy link
Author

Sonu0305 commented Jun 8, 2025

Please stop repeatedly force pushing, it confuses GitHub.

Sorry.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

What is the way to restore the current behavior? I.e. to create a parser without description?

@brianschubert
Copy link
Member

@Sonu0305 it's generally best to avoid force pushing once you've received feedback, since it makes it harder for reviewers to see what changed. PRs are squash merged anyway

@Sonu0305
Copy link
Author

@Sonu0305 it's generally best to avoid force pushing once you've received feedback, since it makes it harder for reviewers to see what changed. PRs are squash merged anyway

Sorry, I pushed a commit with wrong changes, hence I decided to force push, I will surely avoid this and keep in mind.
Sorry & Thanks again.

@Sonu0305
Copy link
Author

What is the way to restore the current behavior? I.e. to create a parser without description?

New changes, help in a way, where description is set to default only when help is not None, and the user does not provide description explicitly.
Let me know if this is the expected behaviour,
Thank You.

@serhiy-storchaka
Copy link
Member

What if the user wants help but no description?

@Sonu0305
Copy link
Author

Sonu0305 commented Jun 11, 2025

What if the user wants help but no description?

The user can set description to None.
I can add tests for this case as well.
And if required, we can document it as well.

@serhiy-storchaka
Copy link
Member

Yes, please add a test. Add also tests for either help or description are SUPPRESS.

This needs also documentation, and it is difficult to find a good place for it, because add_parser() is not documented separately, but as a part of add_subparsers() which has its own parameters. The best place is perhaps somewhere near a paragraph that starts with "Similarly, when a help message is requested from a subparser, only the help for that particular parser will be printed." You will need also to update the following example. Be concise. Add a versionchanged directive after the example. These are just tips, you may find something better. Rewrite the existing text if it makes the result better.

cc @savannahostrowski

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

Successfully merging this pull request may close these issues.

argparse._SubParsersAction.add_parser should default to description matching help
4 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.