← baseline_full_v2

rich_3052

failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · Textualize/rich

Task input

Case insensitive prompt choices

## Type of changes

- [ ] Bug fix
- [x] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other

## Checklist

- [x] I've run the latest [black](https://github.com/psf/black) with default args on new code.
- [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [x] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.

## Description

Optional flag for `Prompt.ask` allowing case-insensitive responses. Just add `case_sensitive=False` to the command options:

```python
from rich.prompt import Prompt
name = Prompt.ask("Enter your name", choices=["Paul", "Jessica", "Duncan"], default="Paul", case_sensitive=False)
```

Now, it would accept "paul" or "Paul" as valid responses. Defaults to True, which is the usual result.


Tool calls (0)

#ToolArgumentsResult
No trace captured.

Test output

show
.F
=================================== FAILURES ===================================
_______________________ test_prompt_str_case_insensitive _______________________

    def test_prompt_str_case_insensitive():
        INPUT = "egg\nFoO"
        console = Console(file=io.StringIO())
>       name = Prompt.ask(
            "what is your name",
            console=console,
            choices=["foo", "bar"],
            default="baz",
            case_sensitive=False,
            stream=io.StringIO(INPUT),
        )
E       TypeError: PromptBase.ask() got an unexpected keyword argument 'case_sensitive'

tests/test_prompt.py:27: TypeError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 1 passed in 0.13s