diff options
author | ivasenkov15 <ivasenkov15@yandex-team.com> | 2024-01-23 12:12:09 +0300 |
---|---|---|
committer | ivasenkov15 <ivasenkov15@yandex-team.com> | 2024-01-23 12:25:24 +0300 |
commit | 4f5160da6ac3805c99917f6448de98460ea8668e (patch) | |
tree | 2cf77ab47a1934c8fac76432acc2560d86630566 /contrib/python/ipython/py3/IPython/terminal | |
parent | 0852227e74fca796397668972f80a973c6b3e011 (diff) | |
download | ydb-4f5160da6ac3805c99917f6448de98460ea8668e.tar.gz |
fix bank-applications: remove bank-forms usage
Diffstat (limited to 'contrib/python/ipython/py3/IPython/terminal')
-rw-r--r-- | contrib/python/ipython/py3/IPython/terminal/interactiveshell.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py index 532287f5e7..fcb816eb17 100644 --- a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py +++ b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py @@ -1,8 +1,8 @@ """IPython terminal interface using prompt_toolkit""" -import asyncio import os import sys +import inspect from warnings import warn from typing import Union as UnionType, Optional @@ -66,8 +66,8 @@ from .shortcuts.auto_suggest import ( PTK3 = ptk_version.startswith('3.') -class _NoStyle(Style): pass - +class _NoStyle(Style): + pass _style_overrides_light_bg = { @@ -84,6 +84,20 @@ _style_overrides_linux = { Token.OutPromptNum: '#ansired bold', } + +def _backward_compat_continuation_prompt_tokens(method, width: int, *, lineno: int): + """ + Sagemath use custom prompt and we broke them in 8.19. + """ + sig = inspect.signature(method) + if "lineno" in inspect.signature(method).parameters or any( + [p.kind == p.VAR_KEYWORD for p in sig.parameters.values()] + ): + return method(width, lineno=lineno) + else: + return method(width) + + def get_default_editor(): try: return os.environ['EDITOR'] @@ -96,7 +110,8 @@ def get_default_editor(): if os.name == 'posix': return 'vi' # the only one guaranteed to be there! else: - return 'notepad' # same in Windows! + return "notepad" # same in Windows! + # conservatively check for tty # overridden streams can result in things like: @@ -293,7 +308,6 @@ class TerminalInteractiveShell(InteractiveShell): return self.editing_mode - @observe('editing_mode') def _editing_mode(self, change): if self.pt_app: @@ -322,7 +336,6 @@ class TerminalInteractiveShell(InteractiveShell): def refresh_style(self): self._style = self._make_style_from_name_or_cls(self.highlighting_style) - highlighting_style_overrides = Dict( help="Override highlighting format for specific tokens" ).tag(config=True) @@ -764,7 +777,9 @@ class TerminalInteractiveShell(InteractiveShell): "message": get_message, "prompt_continuation": ( lambda width, lineno, is_soft_wrap: PygmentsTokens( - self.prompts.continuation_prompt_tokens(width, lineno=lineno) + _backward_compat_continuation_prompt_tokens( + self.prompts.continuation_prompt_tokens, width, lineno=lineno + ) ) ), "multiline": True, @@ -859,7 +874,6 @@ class TerminalInteractiveShell(InteractiveShell): for cmd in ('clear', 'more', 'less', 'man'): self.alias_manager.soft_define_alias(cmd, cmd) - def __init__(self, *args, **kwargs) -> None: super(TerminalInteractiveShell, self).__init__(*args, **kwargs) self._set_autosuggestions(self.autosuggestions_provider) @@ -868,7 +882,6 @@ class TerminalInteractiveShell(InteractiveShell): self.keep_running = True self._set_formatter(self.autoformatter) - def ask_exit(self): self.keep_running = False @@ -916,7 +929,6 @@ class TerminalInteractiveShell(InteractiveShell): self._atexit_once() - _inputhook = None def inputhook(self, context): if self._inputhook is not None: |