From ae0652cd6f8e6ab2351e0773bfbbe2cd89bfe0fa 2017-04-18 16:37:34 From: Matthias Bussonnier Date: 2017-04-18 16:37:34 Subject: [PATCH] Backport PR #10373 on branch 5.x Make the TerminalInteractiveShell class configurable. --- diff --git a/IPython/terminal/ipapp.py b/IPython/terminal/ipapp.py index 8add461..30cb93d 100755 --- a/IPython/terminal/ipapp.py +++ b/IPython/terminal/ipapp.py @@ -35,7 +35,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 ) #----------------------------------------------------------------------------- @@ -185,6 +185,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.""" @@ -320,7 +327,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 3bdbc3e..842b275 100644 --- a/docs/source/whatsnew/development.rst +++ b/docs/source/whatsnew/development.rst @@ -10,7 +10,6 @@ This document describes in-flight development work. conflicts for other Pull Requests). Instead, create a new file in the `docs/source/whatsnew/pr` folder - .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT. diff --git a/docs/source/whatsnew/version5.rst b/docs/source/whatsnew/version5.rst index cca35bc..e1b9fed 100644 --- a/docs/source/whatsnew/version5.rst +++ b/docs/source/whatsnew/version5.rst @@ -2,6 +2,20 @@ 5.x Series ============ +IPython 5.4 +=========== + +Configurable TerminalInteractiveShell +------------------------------------- + +Backported from the 6.x branch as an exceptional new feature. See +:ghpull:`10373` and :ghissue:`10364` + +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. + IPython 5.3 ===========