Skip to content

Conversation

@Celina1801
Copy link

@Celina1801 Celina1801 commented Jan 27, 2025

What is the problem that this PR addresses?

Closes #413
The issue addressed by this PR is the inability to handle non-string items in choice prompts. Previously, using lists or arrays containing integers, floats, booleans, or other non-string objects in the choices parameter caused runtime errors. This limitation impacted use cases requiring dynamic, type-diverse choices.

How did you solve it?

The solution involves enhancing the Choice.build method and related components in common.py to support non-string objects. Specifically:

The Choice.build method now converts non-string items into displayable strings for rendering while preserving their original type as the choice value.
Updated logic in InquirerControl to handle the mixed types seamlessly, ensuring compatibility with existing features such as shortcuts and separators.
Comprehensive unit tests were added to validate the behavior with non-string items, covering integers, floats, booleans, and mixed-type lists.

Checklist

  • I have read the Contributor's Guide.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@tmbo tmbo enabled auto-merge August 28, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't create a choice prompt for non string lists?

2 participants