-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
GH-130645: Default to color help in argparse #136809
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I like these:-)
Requested color expert. I think this can be skip-news since there is no change to the content? I see there was a NEWS entry for the previous PR, it was general enough that we could put it under it if that is possible?
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can approve again if you really want me to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale makes sense. My only concern would be cmd.exe
on Windows, where I've had bad experiences with ANSI codes before, but local testing demonstrates that things seem to be working.
A
🤖 New build scheduled with the buildbot fleet by @hugovk for commit 0abf68e 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136809%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, this looks so good! Thanks for making the PR. Just one small comment re. docs!
We've gotten a lot of approvals on this PR 😃 and I intend to merge it imminently. @hugovk We're good to get this into 3.14, yeah? If so, I'll add the backport to 3.14 label before merge. |
Yes, good to backport to 3.14. |
Thanks @pablogsal for the PR, and @savannahostrowski for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
(cherry picked from commit acbe896cb12d6a92e6150fff22921756f6928035) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
GH-136886 is a backport of this pull request to the 3.14 branch. |
) GH-130645: Default to color help in argparse (GH-136809) (cherry picked from commit acbe896) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Colored help significantly improves readability and user experience by helping users visually group and separate different sections, options, and arguments. Modern terminals overwhelmingly support ANSI color codes, and most contemporary programming languages and CLI tools now default to colored output when appropriate.
This change aligns Python's argparse with current standards where color is the expected default behavior. Users find colored output particularly valuable for quickly scanning and understanding command-line help, as it creates natural visual hierarchy and reduces cognitive load when parsing complex option lists.
The existing color detection logic already gracefully falls back to plain text on unsupported terminals, ensuring backwards compatibility. Users who prefer monochrome output retain full control through standard terminal preferences and environment variables.
argparse
help #130645