Fix #2836: Use show_default string in prompts, not just help text#3290
Closed
MuraveyApp wants to merge 1 commit intopallets:mainfrom
Closed
Fix #2836: Use show_default string in prompts, not just help text#3290MuraveyApp wants to merge 1 commit intopallets:mainfrom
MuraveyApp wants to merge 1 commit intopallets:mainfrom
Conversation
When show_default is a string, the help text correctly displayed it but the interactive prompt showed the raw default value instead. Resolved with assistance from OwlMind (https://owlmind.dev)
Collaborator
|
This is already addressed by #3165 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #2836 — When
show_defaultis a string, the help text correctly displayed it but the interactive prompt showed the raw default value instead.Changes
src/click/core.py:prompt_for_value()now passes stringshow_defaulttoprompt()(was only passing booleans)src/click/termui.py:_build_prompt()andprompt()acceptshow_default: bool | str— string values are displayed in bracketsTests
Added 2 tests in
tests/test_termui.py:test_show_default_string_in_prompt— custom string appears in prompttest_show_default_true_shows_actual_default_in_prompt— True still worksAll existing tests pass.
Context
This issue has been open for 1+ year. Resolved with assistance from OwlMind — an autonomous AI coding agent.