diff --git a/IPython/core/events.py b/IPython/core/events.py index 5051acc..8748777 100644 --- a/IPython/core/events.py +++ b/IPython/core/events.py @@ -106,7 +106,7 @@ def pre_execute(): pass @_collect -def pre_execute_explicit(): +def pre_run_cell(): """Fires before user-entered code runs.""" pass @@ -118,7 +118,7 @@ def post_execute(): pass @_collect -def post_execute_explicit(): +def post_run_cell(): """Fires after user-entered code runs.""" pass diff --git a/IPython/core/hooks.py b/IPython/core/hooks.py index d19e685..9bec922 100644 --- a/IPython/core/hooks.py +++ b/IPython/core/hooks.py @@ -49,7 +49,7 @@ __all__ = ['editor', 'fix_error_editor', 'synchronize_with_editor', 'show_in_pager','pre_prompt_hook', 'pre_run_code_hook', 'clipboard_get'] -deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_execute_explicit' event", +deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_run_cell' event", 'late_startup_hook': "a callback for the 'shell_initialised' event", 'shutdown_hook': "the atexit module", } diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index db36f3d..aeb0d92 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -844,13 +844,13 @@ class InteractiveShell(SingletonConfigurable): self.events = EventManager(self, available_events) def register_post_execute(self, func): - """DEPRECATED: Use ip.callbacks.register('post_execute_explicit', func) + """DEPRECATED: Use ip.callbacks.register('post_run_cell', func) Register a function for calling after code execution. """ warn("ip.register_post_execute is deprecated, use " - "ip.callbacks.register('post_execute_explicit', func) instead.") - self.events.register('post_execute_explicit', func) + "ip.callbacks.register('post_run_cell', func) instead.") + self.events.register('post_run_cell', func) #------------------------------------------------------------------------- # Things related to the "main" module @@ -2669,7 +2669,7 @@ class InteractiveShell(SingletonConfigurable): self.events.trigger('pre_execute') if not silent: - self.events.trigger('pre_execute_explicit') + self.events.trigger('pre_run_cell') # If any of our input transformation (input_transformer_manager or # prefilter_manager) raises an exception, we store it in this variable @@ -2742,7 +2742,7 @@ class InteractiveShell(SingletonConfigurable): self.events.trigger('post_execute') if not silent: - self.events.trigger('post_execute_explicit') + self.events.trigger('post_run_cell') if store_history: # Write output to the database. Does nothing unless diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 15ca8c1..5a1f795 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -282,15 +282,15 @@ class InteractiveShellTestCase(unittest.TestCase): self.assertEqual(ip.var_expand(u"{1/0}"), u"{1/0}") def test_silent_postexec(self): - """run_cell(silent=True) doesn't invoke pre/post_execute_explicit callbacks""" + """run_cell(silent=True) doesn't invoke pre/post_run_cell callbacks""" pre_explicit = mock.Mock() pre_always = mock.Mock() post_explicit = mock.Mock() post_always = mock.Mock() - ip.events.register('pre_execute_explicit', pre_explicit) + ip.events.register('pre_run_cell', pre_explicit) ip.events.register('pre_execute', pre_always) - ip.events.register('post_execute_explicit', post_explicit) + ip.events.register('post_run_cell', post_explicit) ip.events.register('post_execute', post_always) try: diff --git a/IPython/extensions/autoreload.py b/IPython/extensions/autoreload.py index b78b924..b5e2ece 100644 --- a/IPython/extensions/autoreload.py +++ b/IPython/extensions/autoreload.py @@ -490,7 +490,7 @@ class AutoreloadMagics(Magics): # Inject module to user namespace self.shell.push({top_name: top_module}) - def pre_execute_explicit(self): + def pre_run_cell(self): if self._reloader.enabled: try: self._reloader.check() @@ -502,4 +502,4 @@ def load_ipython_extension(ip): """Load the extension in IPython.""" auto_reload = AutoreloadMagics(ip) ip.register_magics(auto_reload) - ip.events.register('pre_execute_explicit', auto_reload.pre_execute_explicit) + ip.events.register('pre_run_cell', auto_reload.pre_run_cell) diff --git a/IPython/extensions/tests/test_autoreload.py b/IPython/extensions/tests/test_autoreload.py index 5f30a97..d3b061e 100644 --- a/IPython/extensions/tests/test_autoreload.py +++ b/IPython/extensions/tests/test_autoreload.py @@ -23,7 +23,7 @@ import nose.tools as nt import IPython.testing.tools as tt from IPython.extensions.autoreload import AutoreloadMagics -from IPython.core.events import EventManager, pre_execute_explicit +from IPython.core.events import EventManager, pre_run_cell from IPython.utils.py3compat import PY3 if PY3: @@ -41,14 +41,14 @@ class FakeShell(object): def __init__(self): self.ns = {} - self.events = EventManager(self, {'pre_execute_explicit', pre_execute_explicit}) + self.events = EventManager(self, {'pre_run_cell', pre_run_cell}) self.auto_magics = AutoreloadMagics(shell=self) - self.events.register('pre_execute_explicit', self.auto_magics.pre_execute_explicit) + self.events.register('pre_run_cell', self.auto_magics.pre_run_cell) register_magics = set_hook = noop def run_code(self, code): - self.events.trigger('pre_execute_explicit') + self.events.trigger('pre_run_cell') exec(code, self.ns) def push(self, items):