PyInquirer
PyInquirer copied to clipboard
Default value is not added to answers if when evaluates to False
import PyInquirer
answers = PyInquirer.prompt(
[
{
"type": "confirm",
"message": "Do it:",
"name": "DO_IT",
"default: True,
"when": lambda x: "THING" in x,
}
]
)
print(answers) # {}
I would have expected the result to be {"DO_IT": True}, because that is the default. My expectation is the default is resolved even if not asked - in fact, it is my opinion that the default is especially important if the question is not asked.
This could be solved by adding the default to the answers dictionary before the when is evaluated.