diff --git a/IPython/core/hooks.py b/IPython/core/hooks.py index fa732f7..09b08d9 100644 --- a/IPython/core/hooks.py +++ b/IPython/core/hooks.py @@ -44,10 +44,13 @@ from .error import TryNext # List here all the default hooks. For now it's just the editor functions # but over time we'll move here all the public API for user-accessible things. -__all__ = ['editor', 'synchronize_with_editor', - 'shutdown_hook', 'late_startup_hook', - 'show_in_pager','pre_prompt_hook', - 'pre_run_code_hook', 'clipboard_get'] +__all__ = [ + "editor", + "synchronize_with_editor", + "show_in_pager", + "pre_prompt_hook", + "clipboard_get", +] deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_run_cell' event", 'late_startup_hook': "a callback for the 'shell_initialized' event", @@ -132,23 +135,6 @@ class CommandChainDispatcher: return iter(self.chain) -def shutdown_hook(self): - """ default shutdown hook - - Typically, shutdown hooks should raise TryNext so all shutdown ops are done - """ - - #print "default shutdown hook ok" # dbg - return - - -def late_startup_hook(self): - """ Executed after ipython has been constructed and configured - - """ - #print "default startup hook ok" # dbg - - def show_in_pager(self, data, start, screen_lines): """ Run a string through pager """ # raising TryNext here will use the default paging functionality @@ -165,11 +151,6 @@ def pre_prompt_hook(self): return None -def pre_run_code_hook(self): - """ Executed before running the (prefiltered) code in IPython """ - return None - - def clipboard_get(self): """ Get text from the clipboard. """ diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 6b966c9..0f75337 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -561,7 +561,6 @@ class InteractiveShell(SingletonConfigurable): self.init_pdb() self.init_extension_manager() self.init_payload() - self.hooks.late_startup_hook() self.events.trigger('shell_initialized', self) atexit.register(self.atexit_operations) @@ -868,13 +867,12 @@ class InteractiveShell(SingletonConfigurable): for hook_name in hooks.__all__: # default hooks have priority 100, i.e. low; user hooks should have # 0-100 priority - self.set_hook(hook_name,getattr(hooks,hook_name), 100, _warn_deprecated=False) + self.set_hook(hook_name, getattr(hooks, hook_name), 100) if self.display_page: self.set_hook('show_in_pager', page.as_hook(page.display_page), 90) - def set_hook(self,name,hook, priority=50, str_key=None, re_key=None, - _warn_deprecated=True): + def set_hook(self, name, hook, priority=50, str_key=None, re_key=None): """set_hook(name,hook) -> sets an internal IPython hook. IPython exposes some of its internal API as user-modifiable hooks. By @@ -904,7 +902,7 @@ class InteractiveShell(SingletonConfigurable): print("Warning! Hook '%s' is not one of %s" % \ (name, IPython.core.hooks.__all__ )) - if _warn_deprecated and (name in IPython.core.hooks.deprecated): + if name in IPython.core.hooks.deprecated: alternative = IPython.core.hooks.deprecated[name] raise ValueError( "Hook {} has been deprecated since IPython 5.0. Use {} instead.".format( @@ -3247,7 +3245,6 @@ class InteractiveShell(SingletonConfigurable): outflag = True # happens in more places, so it's easier as default try: try: - self.hooks.pre_run_code_hook() if async_: await eval(code_obj, self.user_global_ns, self.user_ns) else: @@ -3631,9 +3628,6 @@ class InteractiveShell(SingletonConfigurable): del self.tempdirs - # Run user hooks - self.hooks.shutdown_hook() - def cleanup(self): self.restore_sys_module_state()