Ensure confirm() returns a boolean after Enter#2077
Open
zhangli091011 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
prompt_toolkit.shortcuts.confirm()returning an empty string when Enter is pressed without selecting an answer.Enter previously fell through to
PromptSession's normal accept binding, which returned the empty buffer contents. The confirmation session now handles Enter explicitly and continues waiting foryorn, so successful results remainTrueorFalse.The CI environment's current mypy/typeshed versions also exposed an incompatible return annotation in the existing custom PDB trace dispatcher. Its internal return annotation is now
Any, matching the range of values accepted by the debugger API without changing runtime behavior.Fixes #2046.
Tests
y,Y,n, andN.venv\Scripts\python.exe -m pytest tests/test_shortcuts.py -q -k confirmruff check src/prompt_toolkit/shortcuts/prompt.py tests/test_shortcuts.pyruff format --check src/prompt_toolkit/shortcuts/prompt.py tests/test_shortcuts.pytypos .AI disclosure
OpenCode using
myself/gpt-5.6-solassisted with issue investigation, implementation, and test preparation. I reviewed the change and verification results.