diff options
| author | robot-contrib <[email protected]> | 2023-10-14 09:57:42 +0300 |
|---|---|---|
| committer | robot-contrib <[email protected]> | 2023-10-14 10:17:49 +0300 |
| commit | f13bfc9a1e469983083b02e19cf963678ace66c0 (patch) | |
| tree | 08bbf5b3ec11f1ce4aa614c451089b74caec35e2 /contrib/python/ipython/py3/IPython/terminal | |
| parent | 82c487106cdf6fa8ae9a18967e53de52fb52e4e8 (diff) | |
Update contrib/python/ipython/py3 to 8.16.0
Diffstat (limited to 'contrib/python/ipython/py3/IPython/terminal')
4 files changed, 21 insertions, 11 deletions
diff --git a/contrib/python/ipython/py3/IPython/terminal/embed.py b/contrib/python/ipython/py3/IPython/terminal/embed.py index ce5ee01ff18..59fa6106776 100644 --- a/contrib/python/ipython/py3/IPython/terminal/embed.py +++ b/contrib/python/ipython/py3/IPython/terminal/embed.py @@ -158,6 +158,12 @@ class InteractiveShellEmbed(TerminalInteractiveShell): assert ( "user_global_ns" not in kw ), "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0." + # temporary fix for https://github.com/ipython/ipython/issues/14164 + cls = type(self) + if cls._instance is None: + for subclass in cls._walk_mro(): + subclass._instance = self + cls._instance = self clid = kw.pop('_init_location_id', None) if not clid: diff --git a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py index 37e0b86981e..9b63159dfa5 100644 --- a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py +++ b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py @@ -4,7 +4,7 @@ import asyncio import os import sys from warnings import warn -from typing import Union as UnionType +from typing import Union as UnionType, Optional from IPython.core.async_helpers import get_asyncio_loop from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC @@ -912,8 +912,9 @@ class TerminalInteractiveShell(InteractiveShell): if self._inputhook is not None: self._inputhook(context) - active_eventloop = None - def enable_gui(self, gui=None): + active_eventloop: Optional[str] = None + + def enable_gui(self, gui: Optional[str] = None) -> None: if self.simple_prompt is True and gui is not None: print( f'Cannot install event loop hook for "{gui}" when running with `--simple-prompt`.' @@ -928,8 +929,15 @@ class TerminalInteractiveShell(InteractiveShell): return if self._inputhook is not None and gui is not None: - print( - f"Shell is already running a gui event loop for {self.active_eventloop}. " + newev, newinhook = get_inputhook_name_and_func(gui) + if self._inputhook == newinhook: + # same inputhook, do nothing + self.log.info( + f"Shell is already running the {self.active_eventloop} eventloop. Doing nothing" + ) + return + self.log.warning( + f"Shell is already running a different gui event loop for {self.active_eventloop}. " "Call with no arguments to disable the current loop." ) return diff --git a/contrib/python/ipython/py3/IPython/terminal/ipapp.py b/contrib/python/ipython/py3/IPython/terminal/ipapp.py index 6280bce3b20..eed452c935c 100644 --- a/contrib/python/ipython/py3/IPython/terminal/ipapp.py +++ b/contrib/python/ipython/py3/IPython/terminal/ipapp.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # encoding: utf-8 """ The :class:`~traitlets.config.application.Application` object for the command @@ -337,7 +336,3 @@ def load_default_config(ipython_dir=None): return app.config launch_new_instance = TerminalIPythonApp.launch_instance - - -if __name__ == '__main__': - launch_new_instance() diff --git a/contrib/python/ipython/py3/IPython/terminal/pt_inputhooks/__init__.py b/contrib/python/ipython/py3/IPython/terminal/pt_inputhooks/__init__.py index 9043f15e86b..22a681e249f 100644 --- a/contrib/python/ipython/py3/IPython/terminal/pt_inputhooks/__init__.py +++ b/contrib/python/ipython/py3/IPython/terminal/pt_inputhooks/__init__.py @@ -1,5 +1,6 @@ import importlib import os +from typing import Tuple, Callable aliases = { 'qt4': 'qt', @@ -119,7 +120,7 @@ def set_qt_api(gui): return qt_env2gui[QT_API] -def get_inputhook_name_and_func(gui): +def get_inputhook_name_and_func(gui: str) -> Tuple[str, Callable]: if gui in registered: return gui, registered[gui] |
