Skip to content

When prompting, use show_default as the default if its a string#2837

Closed
thejcannon wants to merge 9 commits intopallets:mainfrom
thejcannon:patch-1
Closed

When prompting, use show_default as the default if its a string#2837
thejcannon wants to merge 9 commits intopallets:mainfrom
thejcannon:patch-1

Conversation

@thejcannon
Copy link
Copy Markdown

@thejcannon thejcannon commented Jan 6, 2025

This PR just makes sure the default handed to .prompt is the show_default if its a string (to match the help).

fixes #2836

  • Add tests that demonstrate the correct behavior of the change. Tests
    should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.

@thejcannon
Copy link
Copy Markdown
Author

oh duh, this changes the default 🤦 . Gotta go deeper...

@thejcannon thejcannon marked this pull request as ready for review January 7, 2025 02:03
if type is not None and show_choices and isinstance(type, Choice):
prompt += f" ({', '.join(map(str, type.choices))})"
if isinstance(show_default, str):
default = f"({show_default})"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be `default = f"{prompt} ({show_default})". Also add this to the test.

@Rowlando13
Copy link
Copy Markdown
Collaborator

Please rebase on main to resolve the changes.rst. With merge after #3030.

@Rowlando13 Rowlando13 added the bug label Aug 23, 2025
@Rowlando13 Rowlando13 marked this pull request as draft August 23, 2025 08:02
@thejcannon thejcannon closed this by deleting the head repository Oct 30, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2025
@kdeldycke kdeldycke added the f:prompt feature: prompt for input label Mar 25, 2026
@kdeldycke kdeldycke added this to the 8.3.3 milestone Mar 25, 2026
@kdeldycke
Copy link
Copy Markdown
Collaborator

A PR is ready to be merged at: #3165

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug f:prompt feature: prompt for input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

show_default as a string isn't used in prompts as the default shown

3 participants