GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity by savannahostrowski · Pull Request #144983 · python/cpython

Conversation

@savannahostrowski

@savannahostrowski savannahostrowski commented Feb 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

In 66b3922 (gh-117766), argparse was changed to use str() instead of repr() when displaying choices in error messages. This was done to improve StrEnum display, but had the side effect of removing quotes from string choices, making error messages less clear and inconsistent with the documentation.

  • Issue: Wrong output example on invalid options documentation #130750

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@savannahostrowski
Ensure quotes around suggestions
4c79b5a
@savannahostrowski savannahostrowski added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Feb 19, 2026
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 19, 2026
@savannahostrowski savannahostrowski changed the title GH-130751: Restore quoting of choices in argparse error messages to match documentation and improve clarity GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity Feb 19, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 19, 2026
Wrong output example on invalid options documentation #130750
Closed
@blurb-it
📜🤖 Added by blurb_it.
f29635d
@savannahostrowski savannahostrowski mentioned this pull request Feb 19, 2026
gh-130750: Fix invalid choices documentation #130751
Closed
@savannahostrowski
Merge branch 'main' into fix-suggestion
0330428
sobolevn
sobolevn approved these changes Feb 19, 2026
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

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 support explicit quotes, because bar in Python is a variable name, 'bar' is a string. 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

savannahostrowski reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 19, 2026
@savannahostrowski
Merge branch 'main' into fix-suggestion
82d0715
@savannahostrowski
savannahostrowski enabled auto-merge (squash) February 23, 2026 17:09
@savannahostrowski
savannahostrowski disabled auto-merge February 23, 2026 17:14
@savannahostrowski

savannahostrowski commented Feb 23, 2026

Copy link
Copy Markdown
Member Author

@serhiy-storchaka Mind taking a look at this one, since you were involved in the merge of the PR that changed this display?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Feb 23, 2026

Copy link
Copy Markdown
Member

Looking how is this handled in other programs. On Linux:

$ ls --color=xyz
error: invalid value 'xyz' for '--color[=<color>]'

  [possible values: always, auto, never]

For more information, try '--help'.

On FreeBSD:

$ ls --color=xyz
ls: unsupported --color value 'xyz' (must be always, auto, or never)

Both quote the invalid value, but do not quote the list of valid values.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@savannahostrowski

savannahostrowski commented Feb 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There are also plenty of command-line tools that do quote valid choices in error messages, so it's a mixed bag across the ecosystem, I think.

My preference would be to restore the previous quoting behavior here. The PR that changed the display wasn't really about removing quotes; it was about fixing StrEnum, and the loss of quotes was an acknowledged side effect.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed May 4, 2026
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

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.

Well, argparce deviated enough from the original getopt.c, so we can not follow it in this particular detail.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/argparse.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

savannahostrowski added 4 commits May 4, 2026 11:20
@savannahostrowski
Merge branch 'main' into fix-suggestion
7682569
@savannahostrowski
Merge branch 'fix-suggestion' of https://github.com/savannahostrowski…
b70ed30
…/cpython into fix-suggestion
@savannahostrowski
Just quote everything, since its all a str anyway
75defab
@savannahostrowski
Merge branch 'main' into fix-suggestion
fcf76a7
serhiy-storchaka
serhiy-storchaka approved these changes May 4, 2026
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

savannahostrowski reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@savannahostrowski
Merge branch 'main' into fix-suggestion
1d14d66
@savannahostrowski
savannahostrowski enabled auto-merge (squash) May 4, 2026 20:55
savannahostrowski added 2 commits May 4, 2026 14:16
@savannahostrowski
Missed tests
0625164
@savannahostrowski
one more test
e33550c
@savannahostrowski
savannahostrowski merged commit 53a7f76 into python:main May 4, 2026
52 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label May 4, 2026
@miss-islington-app

miss-islington-app Bot commented May 4, 2026

Copy link
Copy Markdown

Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented May 4, 2026

Copy link
Copy Markdown

Sorry, @savannahostrowski, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 53a7f76501923059188922be231db855265fe9a4 3.14
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned savannahostrowski May 4, 2026
@miss-islington-app

miss-islington-app Bot commented May 4, 2026

Copy link
Copy Markdown

Sorry, @savannahostrowski, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 53a7f76501923059188922be231db855265fe9a4 3.13
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@savannahostrowski savannahostrowski mentioned this pull request May 4, 2026
[3.14] GH-130750: Restore quoting of choices in argparse error messag… #149385
Merged
@bedevere-app

bedevere-app Bot commented May 4, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 4, 2026
@savannahostrowski savannahostrowski mentioned this pull request May 4, 2026
[3.13] GH-130750: Restore quoting of choices in argparse error messag… #149386
Merged
@bedevere-app

bedevere-app Bot commented May 4, 2026

Copy link
Copy Markdown

GH-149386 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 4, 2026
savannahostrowski added a commit that referenced this pull request May 4, 2026
@savannahostrowski
[3.14] GH-130750: Restore quoting of choices in argparse error messag… (
a458589
#149385)

[3.14] GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity (GH-144983)
(cherry picked from commit 53a7f76)
savannahostrowski added a commit that referenced this pull request May 4, 2026
@savannahostrowski
[3.13] GH-130750: Restore quoting of choices in argparse error messag… (
a02beab
#149386)

[3.13] GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity (GH-144983)
(cherry picked from commit 53a7f76)
@jaimergp jaimergp mentioned this pull request May 26, 2026
Make test_sorted_commands_in_error less picky conda/conda#16151
Merged
1 of 3 tasks
@adamchainz adamchainz mentioned this pull request Jun 12, 2026
Fix argparse test assertion adamchainz/django-harlequin#99
Merged
adamchainz added a commit to adamchainz/django-harlequin that referenced this pull request Jun 12, 2026
@adamchainz
Fix argparse test assertion (#99)
c613f1a
The fix from #45 needs fixing for an upstream fix to the original fix:
python/cpython#144983.
@MatusGasparik MatusGasparik mentioned this pull request Jul 13, 2026
commitizen: 4.13.9 -> 4.16.4 NixOS/nixpkgs#539725
Merged
4 of 13 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Aug 1, 2026
feat(moderation): admin re-moderation entry point and catalog sweep script ByronWilliamsCPA/cyo-adventure#529
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@sobolevn sobolevn sobolevn approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@savannahostrowski savannahostrowski

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@savannahostrowski @serhiy-storchaka @sobolevn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.