Inspect continuation prompt signature and pass only viable arguments.#14274
Merged
Carreau merged 3 commits intoipython:mainfrom Jan 8, 2024
Merged
Inspect continuation prompt signature and pass only viable arguments.#14274Carreau merged 3 commits intoipython:mainfrom
Carreau merged 3 commits intoipython:mainfrom
Conversation
tornaria
reviewed
Dec 28, 2023
|
|
||
| .. method:: in_prompt_tokens(cli=None) | ||
| continuation_prompt_tokens(self, cli=None, width=None) | ||
| continuation_prompt_tokens(self, width=None) |
There was a problem hiding this comment.
While you are at it, maybe remove cli=None from the previous method, and the two lines 46-47 below.
|
LGTM, I actually rebuilt ipython with this PR and tried running sagemath to make sure. My suggestion above in patch form: --- a/docs/source/config/details.rst
+++ b/docs/source/config/details.rst
@@ -33,7 +33,7 @@ which defines the defaults. The required interface is like this:
Prompt style definition. *shell* is a reference to the
:class:`~.TerminalInteractiveShell` instance.
- .. method:: in_prompt_tokens(cli=None)
+ .. method:: in_prompt_tokens()
continuation_prompt_tokens(self, width=None)
rewrite_prompt_tokens()
out_prompt_tokens()
@@ -43,9 +43,6 @@ which defines the defaults. The required interface is like this:
For continuation prompts, *width* is an integer representing the width of
the prompt area in terminal columns.
- *cli*, where used, is the prompt_toolkit ``CommandLineInterface`` instance.
- This is mainly for compatibility with the API prompt_toolkit expects.
-
Here is an example Prompt class that will show the current working directory
in the input prompt:
@@ -55,7 +52,7 @@ in the input prompt:
import os
class MyPrompt(Prompts):
- def in_prompt_tokens(self, cli=None):
+ def in_prompt_tokens(self):
return [(Token, os.getcwd()),
(Token.Prompt, ' >>>')]
Maybe you also want to patch out the examples: --- a/examples/Embedding/embed_class_long.py
+++ b/examples/Embedding/embed_class_long.py
@@ -21,7 +21,7 @@
class CustomPrompt(Prompts):
- def in_prompt_tokens(self, cli=None):
+ def in_prompt_tokens(self):
return [
(Token.Prompt, 'In <'),
--- a/examples/utils/cwd_prompt.py
+++ b/examples/utils/cwd_prompt.py
@@ -6,7 +6,7 @@
class MyPrompt(Prompts):
- def in_prompt_tokens(self, cli=None):
+ def in_prompt_tokens(self):
return [(Token, os.getcwd()),
(Token.Prompt, '>>>')]
|
tornaria
approved these changes
Dec 31, 2023
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.
Closes #14273