Skip to content

gh-142389: Add support for backtick colorisation in argparse help text#149375

Open
hugovk wants to merge 3 commits intopython:mainfrom
hugovk:3.15-argparse-help-backticks
Open

gh-142389: Add support for backtick colorisation in argparse help text#149375
hugovk wants to merge 3 commits intopython:mainfrom
hugovk:3.15-argparse-help-backticks

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented May 4, 2026

#142390 added support for displaying text enclosed in backticks in colour for the help description and epilogue.

This PR adds it for individual help.

Also add backticks to python -m test --help:

image

Will add to other stdlib CLIs in a followup.

@hugovk hugovk requested a review from savannahostrowski as a code owner May 4, 2026 18:13
@hugovk hugovk added the stdlib Standard Library Python modules in the Lib/ directory label May 4, 2026
@hugovk hugovk requested a review from AA-Turner as a code owner May 4, 2026 18:13
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32531060 | 📁 Comparing d8f6526 against main (10f950c)

  🔍 Preview build  

3 files changed
± library/argparse.html
± whatsnew/3.15.html
± whatsnew/changelog.html

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

I think there's one edge case here that we haven't considered...and should before extending this to help text. Poking around on GitHub, flake8 uses double backticks to denote code in help text (I also found at least one instance of this in pytest as well but it's not as pervasive). So, right now, with these changes users would see something like this, where there are funky stray backticks and incorrect colouring:

Image

I think if we apply the new regex, update the docs and add a test or two, that should have us covered.

Other than that, I think this looks good. My preference would be to land this feature and then land application of backticks in a separate PR though (i.e. we can leave libregrtest changes for another PR?)

Comment thread Lib/argparse.py Outdated
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 4, 2026

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Co-authored-by: Savannah Ostrowski <savannah@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants