Skip to content
New issue

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

Inconsistency in Documentation or Bug for return value of questionary.prompt() after capture of Keyboard Interrupt (ctrl-c) #385

Open
1 task done
pyth0n1c opened this issue Jul 17, 2024 · 0 comments
Labels
Bug Something isn't working

Comments

@pyth0n1c
Copy link

pyth0n1c commented Jul 17, 2024

Describe the bug

The following documentation states that if a keyboard interrupt is captured during a questionary.prompt() call, then None should be returned: https://github.com/tmbo/questionary/blob/cf10f3e650d1550376a8e908baa0c9811ef72041/docs/pages/advanced.rst#safe

However, the codebase shows that if a Keyboard Interrupt is captured, then it is actually an empty dict {} which should be returned:

I am unsure if the documentation should be updated to reflect the codebase OR the codebase should be updated to reflect the documentation. The fix is simple.

Example

#Run the following example code on the current `master` branch

import questionary
questionary.prompt([{"type":"text","message":"Just enter any string value", "name":"string_value","default":"some_default_value"}])

#Before answering the question, hit Ctrl-C to generate a keyboard input. You should notice the {}, a dict, is returned.

Steps to reproduce

See the example code above

Expected behaviour

According to the documentation, this should return None, but the code actually returns {}, a dict. I am unsure which is correct, so either the code or documentation should be updated to reflect the intended behavior.

Latest version

  • I have checked that this issue occurs on the latest version of questionary.

Questionary version

2.0.1 (and latest commit in repo master: cf10f3e)

Prompt Toolkit version

3.0.36

Operating System

macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant