Skip to content
Discussion options

You must be logged in to vote

typer.prompt is just re-export of click.prompt.
And, to show choices it requires type parameter passed and it should be instance of Choice.

https://github.com/pallets/click/blob/81a482fbfdd5a553cf4704f822ade04c3b102fbc/src/click/termui.py#L69

So, straightforward solution is to pass type parameter as follows:

    prompt_option: ChoiceEnum = typer.prompt(
        ...
        type=click.Choice([e.value for e in ChoiceEnum]),
    )

I will probably also want to specify value_proc=ChoiceEnum to convert the value from str to ChoiceEnum.

import click
import typer
from enum import Enum


class ChoiceEnum(Enum):
    option_one = "opt1"
    option_two = "opt2"
    option_three = "opt3"

app = typer.T…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem investigate
5 participants
Converted from issue

This discussion was converted from issue #472 on September 19, 2025 07:39.