Skip to content

Commit bf4b0bb

Browse files
committed
Preprocess default before rendering the prompt
1 parent 216ed6c commit bf4b0bb

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/click/termui.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ def _build_prompt(
6868
prompt = text
6969
if type is not None and show_choices and isinstance(type, Choice):
7070
prompt += f" ({', '.join(map(str, type.choices))})"
71-
if show_default:
72-
if isinstance(show_default, str):
73-
# Use the custom string for display
74-
prompt = f"{prompt} [({show_default})]"
75-
elif default is not None:
76-
prompt = f"{prompt} [{_format_default(default)}]"
71+
if isinstance(show_default, str):
72+
default = f"({show_default})"
73+
if default is not None and show_default:
74+
prompt = f"{prompt} [{_format_default(default)}]"
7775
return f"{prompt}{suffix}"
7876

7977

0 commit comments

Comments
 (0)