We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I use dataclass objects as the value of a Choice, InquirerPy.inquirer.select returns a dict instead of the original dataclass object.
InquirerPy.inquirer.select
from dataclasses import dataclass from InquirerPy import inquirer from InquirerPy.base.control import Choice @dataclass(order=True) class Foo: x: str y: int choices = [ Choice(Foo("bar", 2), "foo"), Choice(Foo("foo", 1), "bar"), ] assert type(choices[0].value) is Foo choice = inquirer.select(message='Select something', choices=choices).execute() print(repr(choice)) assert type(choice) is Foo # This assertion fails
Maybe I'm misunderstanding something, but I expected the original value to be returned unmodified.
Note that when using a collections.namedtuple object the behaviour is different:
import collections from InquirerPy import inquirer from InquirerPy.base.control import Choice Foo = collections.namedtuple('Foo', ['x', 'y']) choices = [ Choice(value=Foo("bar", 2), name="foo"), Choice(value=Foo("foo", 1), name="bar"), ] assert type(choices[0].value) is Foo choice = inquirer.select(message='Select something', choices=choices).execute() print(choices[0]) assert type(choice) is Foo # This assertion succeeds
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I use dataclass objects as the value of a Choice,
InquirerPy.inquirer.select
returns a dict instead of the original dataclass object.Maybe I'm misunderstanding something, but I expected the original value to be returned unmodified.
Note that when using a collections.namedtuple object the behaviour is different:
The text was updated successfully, but these errors were encountered: