##// END OF EJS Templates
Inspect continuation prompt signature and pass only viable arguments....
Matthias Bussonnier -
Show More
@@ -3,6 +3,7 b''
3 3 import asyncio
4 4 import os
5 5 import sys
6 import inspect
6 7 from warnings import warn
7 8 from typing import Union as UnionType, Optional
8 9
@@ -66,8 +67,8 b' from .shortcuts.auto_suggest import ('
66 67 PTK3 = ptk_version.startswith('3.')
67 68
68 69
69 class _NoStyle(Style): pass
70
70 class _NoStyle(Style):
71 pass
71 72
72 73
73 74 _style_overrides_light_bg = {
@@ -84,6 +85,20 b' _style_overrides_linux = {'
84 85 Token.OutPromptNum: '#ansired bold',
85 86 }
86 87
88
89 def _backward_compat_continuation_prompt_tokens(method, width: int, *, lineno: int):
90 """
91 Sagemath use custom prompt and we broke them in 8.19.
92 """
93 sig = inspect.signature(method)
94 if "lineno" in inspect.signature(method).parameters or any(
95 [p.kind == p.VAR_KEYWORD for p in sig.parameters.values()]
96 ):
97 return method(width, lineno=lineno)
98 else:
99 return method(width)
100
101
87 102 def get_default_editor():
88 103 try:
89 104 return os.environ['EDITOR']
@@ -764,7 +779,9 b' class TerminalInteractiveShell(InteractiveShell):'
764 779 "message": get_message,
765 780 "prompt_continuation": (
766 781 lambda width, lineno, is_soft_wrap: PygmentsTokens(
767 self.prompts.continuation_prompt_tokens(width, lineno=lineno)
782 _backward_compat_continuation_prompt_tokens(
783 self.prompts.continuation_prompt_tokens, width, lineno=lineno
784 )
768 785 )
769 786 ),
770 787 "multiline": True,
@@ -34,7 +34,7 b' which defines the defaults. The required interface is like this:'
34 34 :class:`~.TerminalInteractiveShell` instance.
35 35
36 36 .. method:: in_prompt_tokens(cli=None)
37 continuation_prompt_tokens(self, cli=None, width=None)
37 continuation_prompt_tokens(self, width=None)
38 38 rewrite_prompt_tokens()
39 39 out_prompt_tokens()
40 40
General Comments 0
You need to be logged in to leave comments. Login now