after 3.0.52 questions using a "when" expression and selecting "no" triggers a VSplit crash
Closed this issue · 3 comments
Copier uses questionary 2.1.0 which which looks like it have a open ended dependency on prompt_toolkit. Running a simple questionary in Copier that uses a "when" criteria when answering "no", crashes in 3.0.52. 3.0.51 and earlier is working fine.
Copier template example:
copier.yml
includeFrontend:
type: bool
help: Do you want to include a Web frontend
default: true
includeDocker:
type: bool
help: Do you want to include a Container Backend
default: true
frontendType:
type: str
help: What type of frontend
choices:
- angular
- javascript
when: "{{ includeFrontend }}"
running " copier copy . ." in the folder with the copier.yml, and selecting "no" trigger a crash.
File ".../python3.9/site-packages/questionary/prompts/common.py", line 591, in _fix_unecessary_blank_lines
default_container.get_children()[0].content.get_children()[1].content # type: ignore[attr-defined]
AttributeError: 'VSplit' object has no attribute 'content'
Hi @ur-anbu,
Thanks for reporting the issue! I just tried and could reproduce it.
Unfortunately, this is something that has to be fixed in the questionary repository. It looks like _fix_unecessary_blank_lines in questionary/prompts/common.py assumes a particular layout hierarchy that's being used by PromptSession. This is an internal implementation detail, and something we never guaranteed that this would not change.
Related, prompt_toolkit now has a choice input as part of 3.0.52 with various options you might want to have a look at:
https://python-prompt-toolkit.readthedocs.io/en/stable/pages/asking_for_a_choice.html
Maybe the questionary library could now use this under the hood instead of building on top of PromptSession?
Would you mind opening an issue in the questionary issue tracker and maybe refer to this one?
Hi and thanks. I have opened an issue at questionary:
tmbo/questionary#457
Closing this. The bug has been fixed in questionary==2.1.1.