Title: argparse does not strip the outer [] in a group in color mode · Issue #142332 · python/cpython · GitHub
Open Graph Title: argparse does not strip the outer [] in a group in color mode · Issue #142332 · python/cpython
X Title: argparse does not strip the outer [] in a group in color mode · Issue #142332 · python/cpython
Description: Bug report Without color, argparse strips the outer [] in a group. But it is not stripped with color. The following example: import argparse parser = argparse.ArgumentParser(color=False, prog="PROG") group = parser.add_mutually_exclusive...
Open Graph Description: Bug report Without color, argparse strips the outer [] in a group. But it is not stripped with color. The following example: import argparse parser = argparse.ArgumentParser(color=False, prog="PROG...
X Description: Bug report Without color, argparse strips the outer [] in a group. But it is not stripped with color. The following example: import argparse parser = argparse.ArgumentParser(color=False, prog="...
Opengraph URL: https://github.com/python/cpython/issues/142332
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"argparse does not strip the outer [] in a group in color mode","articleBody":"# Bug report\n\nWithout color, `argparse` strips the outer [] in a group. But it is not stripped with color.\n\nThe following example:\n```py\nimport argparse\n\nparser = argparse.ArgumentParser(color=False, prog=\"PROG\")\ngroup = parser.add_mutually_exclusive_group()\ngroup.add_argument('--foo', action='store_true', help='FOO')\ngroup.add_argument('--spam', help='SPAM')\ngroup.add_argument('badger', nargs='*', help='BADGER')\nprint(parser.format_usage())\n\nparser = argparse.ArgumentParser(color=True, prog=\"PROG\")\ngroup = parser.add_mutually_exclusive_group()\ngroup.add_argument('--foo', action='store_true', help='FOO')\ngroup.add_argument('--spam', help='SPAM')\ngroup.add_argument('badger', nargs='*', help='BADGER')\nprint(parser.format_usage())\n```\noutputs:\n```\nusage: PROG [-h] [--foo | --spam SPAM | badger ...]\n\nusage: PROG [-h] [--foo | --spam SPAM | [badger ...]]\n\n```\n(the latter line in color).\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-142333\n* gh-142356\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2025-12-06T10:42:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/142332/cpython/issues/142332"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1bf6016c-b669-e197-b9ff-669516bcdc6c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D65A:331E62:90D3A6D:BF60C4E:696DF986 |
| html-safe-nonce | 417c86b906ff52a0ad31407126a4aa0604fbd95e45a3037c879804045bdf4c0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjVBOjMzMUU2Mjo5MEQzQTZEOkJGNjBDNEU6Njk2REY5ODYiLCJ2aXNpdG9yX2lkIjoiNDkyNDM4MDQwMTIxNjkxMTc1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ee3b57ab1e223d5fe80d12ed63d3794a9bca0f6cb22f147df38ad896d7996584 |
| hovercard-subject-tag | issue:3701438410 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/142332/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbf80ff07c229268f6d4d065646b6d7ee327ff18ded7ca8e26299e545fe542ab/python/cpython/issues/142332 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbf80ff07c229268f6d4d065646b6d7ee327ff18ded7ca8e26299e545fe542ab/python/cpython/issues/142332 |
| og:image:alt | Bug report Without color, argparse strips the outer [] in a group. But it is not stripped with color. The following example: import argparse parser = argparse.ArgumentParser(color=False, prog="PROG... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7e5ae23c70136152637ceee8d6faceb35596ec46 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width