Skip to content

Commit 850a4cd

Browse files
Added documentation about usage of 'None' in 'PromptSession.prompt()'.
1 parent 064c9e1 commit 850a4cd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

prompt_toolkit/shortcuts/prompt.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,12 +801,18 @@ def prompt(
801801
accept_default: bool = False,
802802
pre_run: Optional[Callable[[], None]] = None) -> _T:
803803
"""
804-
Display the prompt. All the arguments are a subset of the
805-
:class:`~.PromptSession` class itself.
804+
Display the prompt.
806805
807-
This will raise ``KeyboardInterrupt`` when control-c has been pressed
808-
(for abort) and ``EOFError`` when control-d has been pressed (for
809-
exit).
806+
The first set of arguments is a subset of the :class:`~.PromptSession`
807+
class itself. For these, passing in ``None`` will keep the current
808+
values that are active in the session. Passing in a value will set the
809+
attribute for the session, which means that it applies to the current,
810+
but also to the next prompts.
811+
812+
Note that in order to erase a ``Completer``, ``Validator`` or
813+
``AutoSuggest``, you can't use ``None``. Instead pass in a
814+
``DummyCompleter``, ``DummyValidator`` or ``DummyAutoSuggest`` instance
815+
respectively. For a ``Lexer`` you can pass in an empty ``SimpleLexer``.
810816
811817
Additional arguments, specific for this prompt:
812818
@@ -818,6 +824,10 @@ def prompt(
818824
:param accept_default: When `True`, automatically accept the default
819825
value without allowing the user to edit the input.
820826
:param pre_run: Callable, called at the start of `Application.run`.
827+
828+
This method will raise ``KeyboardInterrupt`` when control-c has been
829+
pressed (for abort) and ``EOFError`` when control-d has been pressed
830+
(for exit).
821831
"""
822832
# NOTE: We used to create a backup of the PromptSession attributes and
823833
# restore them after exiting the prompt. This code has been

0 commit comments

Comments
 (0)