prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Session specific prompt method parameters are overwriting prompt session parameters across prompt method calls.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
When creating a prompt session and calling for prompts through the session's prompt method, prompt call-specific parameters can be passed to the method that can overwrite whatever parameters were passed to the session. However, this seems to overwrite the session parameters and not be scoped to that specific method call. Example:
import prompt_toolkit
session = prompt_toolkit.PromptSession()
session.prompt("(1) Enter single line input: ")
session.prompt("(2) Enter multiline input: ", multiline=True)
session.prompt("(3) Enter single line input again: ")
session.prompt("(4) Enter single line input once more: ", multiline=None)
The first and second prompt calls work as specified. However the third and fourth are still multiline inputs. I would expect that the third and fourth prompts be singleline inputs because they do not specify the multiline parameter. However it appears that the multiline parameter passed in the second prompt call is overwriting the session and causing the third and fourth to erroneously be multiline inputs despite them not specifying so at all. This isn't limited just to the multiline parameter it appears other parameters like bottom_toolbar suffer from this unusual behaviour as well.
Is this behaviour a bug or is it intentional? If it is intentional I would still propose changing it because of how unintuitive it is. Parameters should be limited per prompt call and should not affect or overwrite other prompt calls even for the same session.
Note: This behaviour also affects Session.prompt_async
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the PromptSession.prompt and prompt_async entry points and reproduce the four-call example from the issue. Trace how call-specific parameters such as multiline and bottom_toolbar are stored between calls; done means each prompt call uses only its own parameters and later calls retain the intended defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100