From 4c580c1497d56a21acf380031b2b60a22219913a 2022-12-01 00:27:49 From: nfgf Date: 2022-12-01 00:27:49 Subject: [PATCH] Terminology: output is silenced, not disabled. --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 69b4418..12503e9 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2364,9 +2364,9 @@ class InteractiveShell(SingletonConfigurable): result = fn(*args, **kwargs) # The code below prevents the output from being displayed - # when using magics with decodator @output_can_be_disabled + # when using magics with decodator @output_can_be_silenced # when the last Python token in the expression is a ';'. - if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_DISABLED, False): + if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False): if DisplayHook.semicolon_at_end_of_expression(magic_arg_s): return None diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 82728cd..95653dc 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -258,7 +258,7 @@ def _function_magic_marker(magic_kind): MAGIC_NO_VAR_EXPAND_ATTR = "_ipython_magic_no_var_expand" -MAGIC_OUTPUT_CAN_BE_DISABLED = "_ipython_magic_output_can_be_disabled" +MAGIC_OUTPUT_CAN_BE_SILENCED = "_ipython_magic_output_can_be_silenced" def no_var_expand(magic_func): @@ -277,14 +277,14 @@ def no_var_expand(magic_func): return magic_func -def output_can_be_disabled(magic_func): - """Mark a magic function so its output may be disabled. +def output_can_be_silenced(magic_func): + """Mark a magic function so its output may be silenced. - The output is disabled if the Python expression used as a parameter of + The output is silenced if the Python expression used as a parameter of the magic ends in a semicolon, not counting a Python comment that can - follows it. + follow it. """ - setattr(magic_func, MAGIC_OUTPUT_CAN_BE_DISABLED, True) + setattr(magic_func, MAGIC_OUTPUT_CAN_BE_SILENCED, True) return magic_func # Create the actual decorators for public use diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 5d7942f..7b558d5 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -37,7 +37,7 @@ from IPython.core.magic import ( magics_class, needs_local_scope, no_var_expand, - output_can_be_disabled, + output_can_be_silenced, on_off, ) from IPython.testing.skipdoctest import skip_doctest @@ -1195,7 +1195,7 @@ class ExecutionMagics(Magics): @no_var_expand @needs_local_scope @line_cell_magic - @output_can_be_disabled + @output_can_be_silenced def time(self,line='', cell=None, local_ns=None): """Time execution of a Python statement or expression.