Repository navigation
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
PromptSession.prompt()andprompt_async()currently treat an omittedvalidatorargument and an explicitvalidator=Nonethe same way. As a result, a validator configured on a reusable session cannot be cleared for a later prompt.This change distinguishes those two call forms:
validatorpreserves the session validator.validator=Noneclears the session validator.The behavior is implemented for both synchronous and asynchronous prompts, with regression coverage in
tests/test_cli.pyand updated API documentation.Fixes #2159
Verification
NonefailureNonereplacement were also verified for sync and async promptsRelated work
PR #2161 is acknowledged as a documentation-based alternative. It documents the existing workaround and tutorial guidance without changing runtime behavior. This PR addresses the underlying runtime behavior requested in #2159.
Backwards-compatibility consideration
This intentionally changes the meaning of an explicit
validator=Nonepassed toprompt()orprompt_async(): it now clears the session validator. Code that previously relied onNoneleaving an existing validator active should omit the argument instead. Calls that omitvalidator, pass a validator, or use the existing completer and auto-suggest behavior retain their prior semantics.