Closed transfaeries closed 2 years ago
forest/core.py:1305:4: R0913: Too many arguments (6/5) (too-many-arguments)
forest/core.py:1305:4: R0914: Too many local variables (17/15) (too-many-locals)
Not actually sure how to fix these. Like, why are these the limits.
f"{label}{spacer if body else ''}{body}"
for label, body in dict_options.items()
doesn't work well cause I want it to be blank only if all items are blank. And I need the spacer to be blank because later on we use it for confirmation.
is there a pretty way to keep that functionality?
ETA: took care of it by checking for it with any earlier
I actually just found a bug, give me a minute to fix it
Closes #151
Adds an ask_multiple_choice_question function to questionbot core. Currently it allows for 3 behaviours:
if user provides options as a list, print that list with numbers, accepts exact numbers as answers: eg: What is your favourite forest creature? 1) Deer 2) Foxes 3) Faeries 4) Crows
if user provides options as a dict, we use the keys as the labels and accept the exact label eg: What is your favourite forest creature? A) Deer B) Foxes ⛧) Faeries D) Crows
if user provides options as a dict but with empty values, we use only the keys and again, match exactly eg: What is your tshirt size? S M L XL XXL
Requires_confirmation defaults to true and asks users to confirm their choice with a yes or no question.
Possible improvements would be to allow fuzzy matching, possibly behind a flag, that would allow for things like matching user input to values instead of keys, or allowing lowercase answers
Additionally: tests/test_questionbot.py defines a number of test functions, that just test the basic functionality: test_ask_yesno_question test_multiple_choice_dict_emptyval test_multiple_choice_dict_no_confirm test_multiple_choice_dict_with_confirm test_multiple_choice_list_no_confirm test_multiple_choice_list_with_confirm