Skip to content

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

Merged
merged 7 commits into from
Jul 20, 2025

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jul 19, 2025

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.

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.

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?

@hugovk hugovk requested a review from erlend-aasland as a code owner July 19, 2025 14:47
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@pablogsal pablogsal requested review from ambv, vstinner and 1st1 July 19, 2025 15:21
Copy link
Contributor

@ambv ambv left a 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.

Copy link
Member

@AA-Turner AA-Turner left a 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

@hugovk hugovk added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 20, 2025
@bedevere-bot
Copy link

🤖 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.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 20, 2025
Copy link
Member

@savannahostrowski savannahostrowski left a 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!

@savannahostrowski
Copy link
Member

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.

@hugovk
Copy link
Member

hugovk commented Jul 20, 2025

Yes, good to backport to 3.14.

@AA-Turner AA-Turner added the needs backport to 3.14 bugs and security fixes label Jul 20, 2025
@savannahostrowski savannahostrowski merged commit acbe896 into python:main Jul 20, 2025
156 of 159 checks passed
@miss-islington-app
Copy link

Thanks @pablogsal for the PR, and @savannahostrowski for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 20, 2025
(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>
@bedevere-app
Copy link

bedevere-app bot commented Jul 20, 2025

GH-136886 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jul 20, 2025
savannahostrowski pushed a commit that referenced this pull request Jul 20, 2025
)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants