Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-130645: Default to color help in argparse#136809

Merged
savannahostrowski merged 7 commits into
python:mainpython/cpython:mainfrom
pablogsal:mainpablogsal/cpython:mainCopy head branch name to clipboard
Jul 20, 2025
Merged

GH-130645: Default to color help in argparse#136809
savannahostrowski merged 7 commits into
python:mainpython/cpython:mainfrom
pablogsal:mainpablogsal/cpython:mainCopy head branch name to clipboard

Conversation

@pablogsal

@pablogsal pablogsal commented Jul 19, 2025

Copy link
Copy Markdown
Member

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.

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

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
Comment thread Doc/library/argparse.rst Outdated
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@pablogsal pablogsal requested review from 1st1, ambv and vstinner July 19, 2025 15:21

@ambv ambv left a comment

Copy link
Copy Markdown
Contributor

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.

@AA-Turner AA-Turner 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.

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

🤖 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

@savannahostrowski savannahostrowski 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.

Man, this looks so good! Thanks for making the PR. Just one small comment re. docs!

Comment thread Doc/library/argparse.rst
@savannahostrowski

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

hugovk commented Jul 20, 2025

Copy link
Copy Markdown
Member

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

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 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>
@bedevere-app

bedevere-app Bot commented Jul 20, 2025

Copy link
Copy Markdown

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>
@tgbrooks

Copy link
Copy Markdown

It seemed like the previous discussion at #130645 had the consensus of having this opt-in. I'm surprised to see this made opt-out now. For example, @savannahostrowski previously stated "I'm +1 on this, if it's opt-in" but appears to approve of this change. Other commenters from the previous thread that were also in support of making it opt-in include @rhettinger and @sobolevn but haven't commented on this issue. Concerns mentioned included start-up time and breaking of tests. No one in the previous issue made an argument for doing opt-out. It seems to me that making it opt-out is perhaps premature. Was this discussed somewhere else that I've missed? Thanks.

Apologies if this isn't the right place to raise this, I'm not a contributor, I just saw the 3.14rc1 release and noticed this.

@savannahostrowski

Copy link
Copy Markdown
Member

@tgbrooks Yeah, I thought about this more, and I think the risk here is very low. @hugovk did a lot of due diligence around testing performance impact, making it respect NO_COLOR, etc., so my concerns were addressed. As Pablo also mentioned, color aligns with current standards and expectations, so I think this is a great addition.

taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
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>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
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>
ilevkivskyi pushed a commit to python/mypy that referenced this pull request Aug 25, 2025
…" (#19721)

Reverts #19021

After the PR was merged, `color` was changed to `true` for Python 3.14.
Setting it manually is no longer necessary.
python/cpython#136809
https://docs.python.org/3.14/library/argparse.html#color
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…36809) (python#136886)

pythonGH-130645: Default to color help in argparse (pythonGH-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>
jacobtylerwalls pushed a commit to Skyiesac/django that referenced this pull request Dec 22, 2025
jacobtylerwalls pushed a commit to django/django that referenced this pull request Dec 22, 2025
jacobtylerwalls pushed a commit to django/django that referenced this pull request Dec 22, 2025
….14+.

python/cpython#136809 made `color` default to
True in ArgumentParser.

Backport of d0d85cd from main.
jacobtylerwalls pushed a commit to django/django that referenced this pull request Dec 22, 2025
….14+.

python/cpython#136809 made `color` default to
True in ArgumentParser.

Backport of d0d85cd from main.
yshng pushed a commit to OpenTechStrategies/django that referenced this pull request May 17, 2026
….14+.

python/cpython#136809 made `color` default to
True in ArgumentParser.

Backport of d0d85cd from main.
JordanHyatt pushed a commit to JordanHyatt/django that referenced this pull request May 18, 2026
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.

8 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.