Skip to content

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

Closed
Sonu0305 wants to merge 8 commits into
python:mainfrom
Sonu0305:fix_parser
Closed

gh-135227: argparse: Use help as default description in add_parser#135236
Sonu0305 wants to merge 8 commits into
python:mainfrom
Sonu0305:fix_parser

Conversation

@Sonu0305

@Sonu0305 Sonu0305 commented Jun 7, 2025

Copy link
Copy Markdown

@python-cla-bot

python-cla-bot Bot commented Jun 7, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Jun 7, 2025

Copy link
Copy Markdown

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.

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

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

Sonu0305 commented Jun 7, 2025

Copy link
Copy Markdown
Author

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

Thanks.

edit: typo

Comment thread Misc/NEWS.d/next/Library/2025-06-07-15-10-22.gh-issue-135227.LPeDGt.rst Outdated
@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
Copy Markdown
Member

Please stop repeatedly force pushing, it confuses GitHub.

@Sonu0305

Sonu0305 commented Jun 8, 2025

Copy link
Copy Markdown
Author

Please stop repeatedly force pushing, it confuses GitHub.

Sorry.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

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?

Comment thread Lib/argparse.py Outdated
@brianschubert

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

What if the user wants help but no description?

@Sonu0305

Sonu0305 commented Jun 11, 2025

Copy link
Copy Markdown
Author

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
Copy Markdown
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

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 25, 2026
@savannahostrowski

Copy link
Copy Markdown
Member

I'm going to close this as stale, since there's unaddressed feedback and this has been open for quite sometime. Happy to revisit if feedback is addressed.

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

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

argparse._SubParsersAction.add_parser should default to description matching help

5 participants