From c2b5745b426fc6e0867afb04ca2056fa7078f1d4 2017-04-10 21:09:51 From: Matthias Bussonnier Date: 2017-04-10 21:09:51 Subject: [PATCH] Merge pull request #10373 from Carreau/tis-configurable Make the TerminalInteractiveShell class configurable. --- diff --git a/IPython/terminal/ipapp.py b/IPython/terminal/ipapp.py index 32f97e0..19f4199 100755 --- a/IPython/terminal/ipapp.py +++ b/IPython/terminal/ipapp.py @@ -33,7 +33,7 @@ from IPython.extensions.storemagic import StoreMagics from .interactiveshell import TerminalInteractiveShell from IPython.paths import get_ipython_dir from traitlets import ( - Bool, List, Dict, default, observe, + Bool, List, Dict, default, observe, Type ) #----------------------------------------------------------------------------- @@ -183,6 +183,13 @@ class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp): flags = Dict(flags) aliases = Dict(aliases) classes = List() + + interactive_shell_class = Type( + klass=object, # use default_value otherwise which only allow subclasses. + default_value=TerminalInteractiveShell, + help="Class to use to instantiate the TerminalInteractiveShell object. Useful for custom Frontends" + ).tag(config=True) + @default('classes') def _classes_default(self): """This has to be in a method, for TerminalIPythonApp to be available.""" @@ -318,7 +325,7 @@ class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp): # shell.display_banner should always be False for the terminal # based app, because we call shell.show_banner() by hand below # so the banner shows *before* all extension loading stuff. - self.shell = TerminalInteractiveShell.instance(parent=self, + self.shell = self.interactive_shell_class.instance(parent=self, profile_dir=self.profile_dir, ipython_dir=self.ipython_dir, user_ns=self.user_ns) self.shell.configurables.append(self) diff --git a/docs/source/whatsnew/development.rst b/docs/source/whatsnew/development.rst index 1f62e6b..f4abf18 100644 --- a/docs/source/whatsnew/development.rst +++ b/docs/source/whatsnew/development.rst @@ -118,6 +118,15 @@ of these as well to improve user experience with better error messages and hints. +Configurable TerminalInteractiveShell +------------------------------------- + +IPython gained a new ``c.TerminalIPythonApp.interactive_shell_class`` option +that allow to customize the class used to start the terminal frontend. This +should allow user to use custom interfaces, like reviving the former readline +interface which is now a separate package not maintained by the core team. + + Miscs improvements ------------------