-
Notifications
You must be signed in to change notification settings - Fork 103
fix: allow None as argument for kbi_msg
#471
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
base: master
Are you sure you want to change the base?
Conversation
This commit addresses the issue of the keyboard interrupt message always printing, even in cases where it's not needed and is explicitly set to an empty string. This allows users to disable/replace said print when needed, while avoiding the redundant newline that's currenly being printed when `kbi_msg=""`. This commit also introduces the usage of `TYPE_CHECKING` to improve performance in the changed modules.
|
Hi @tmbo, Thank you. |
kiancross
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @Sevrain1 - this fix looks good. Would you be able to add a unit test?
It's probably best to put any TYPE_CHECKING changes in another PR to keep this scoped to a single issue.
|
@kiancross, Thanks. |
This commit adds tests to the `Form` `Prompt` and `Question` classes to ensure no message is printed when a KeyboardInterrupt is raised during an `ask()`/`ask_async()` call where `kbi_msg=None`.
|
@kiancross, Also, I think the |
|
I was just working on the broken CI when you posted your comment. I've removed support for Python 3.9 in #472, and also fixed an issue with the docs build breaking.
Worth creating an issue for this if you think it's something to be persued. Then others e.g., @tmbo can offer thoughts. |
This commit addresses the issue of the keyboard interrupt message always printing, even in cases where it's not needed and is explicitly set to an empty string. This allows users to disable/replace said print when needed, while avoiding the redundant newline that's currently being printed when
kbi_msg="".(The commit also introduces the usage of
TYPE_CHECKINGto improve performance in the changed modules).What is the problem that this PR addresses?
When
kbi_msg=""and aKeyboardInterruptis encountered, the program still calls the prompt's innerprint(), and needlessly prints nothing while adding a redundant newline.There is essentially no way for the user to disable the
kbi_msgand its newline print, even when it's not needed and is breaking the design of the user's program....
How did you solve it?
I've added
Nonean optional argument tokbi_msg.If the user passes any string (even an empty one), it is printed along with a newline.
If the user passes in
None, no text or newline will be printed.This is fully backwards compatible with the current behaviour of
kbi_msg, and simply allows users to pass inNoneto disable this unneeded print....
Checklist