Skip to content

[BUG] Prompt.confirm default #170

@ewels

Description

@ewels

Describe the bug
This isn't exactly a bug, but rather some unexpected behaviour with Confirm.ask().

In some situations I would like to confirm something with the user, but set the default response to Yes instead of No. I thought I'd just stick in a default=True argument to the function to see what happens, and it kind of works 😅 Hitting enter gives the default response. The problem is that the default is shown in brackets but the [y/N] suffix remains unchanged, instead of being [Y/n].

This isn't really a problem for me - I'll just not specify a default (I actually prefer requiring an explicit response, but I was converting from click.confirm() which always has a default). I just thought I'd flag the behaviour.

Feel free to close if it's a feature and not a bug 😄

To Reproduce

from rich.prompt import Confirm
if Confirm.ask("Do you like rich?", default=True):
  print("Is the correct answer!")
else:
  print("Boo")
$ python test.py
Do you like rich? [y/N] (True):
Is the correct answer!

Platform

  • Rich 3.4.0
  • iTerm2
  • Mac OSX

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions