You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I'm presenting a user with a list of choices, this works really nicely:
from pyinputplus import inputMenu
CHOICES = ('Go left', 'Go right')
inputMenu(choices=CHOICES, prompt='Pick a direction')
It would be really nice, however, to do this instead, which isn't supported:
from enum import Enum
from pyinputplus import inputMenu
class Choices(str, Enum):
one = 'Go left'
two = 'Go right'
inputMenu(choices=Choices, prompt='Pick a direction')
Enum classes are iterable, so will pass an isinstance(<enum_cls>, collections.abc.Iterable) test. But they're not, strictly speaking, sequences, which means this line raises an error if I try to feed in an Enum of choices.
Would it be possible to support Enums in inputMenu and inputChoices? I'd be happy to submit a PR if it would be helpful, but I don't know whether changing the validation function in pysimplevalidate would have unintended consequences.
The text was updated successfully, but these errors were encountered:
If I'm presenting a user with a list of choices, this works really nicely:
It would be really nice, however, to do this instead, which isn't supported:
Enum
classes are iterable, so will pass anisinstance(<enum_cls>, collections.abc.Iterable)
test. But they're not, strictly speaking, sequences, which means this line raises an error if I try to feed in anEnum
of choices.Would it be possible to support
Enum
s ininputMenu
andinputChoices
? I'd be happy to submit a PR if it would be helpful, but I don't know whether changing the validation function inpysimplevalidate
would have unintended consequences.The text was updated successfully, but these errors were encountered: