From 6a4a375870b11ed0a2604bb24b8d21cb42e005b0 2021-04-17 01:20:19 From: Matthias Bussonnier Date: 2021-04-17 01:20:19 Subject: [PATCH] Minor syntax cleanup and silification. Remove a syntax warning; and use explicit kwargs instead of kwargs.pop. --- diff --git a/IPython/core/display_functions.py b/IPython/core/display_functions.py index 9f566b4..ab5777a 100644 --- a/IPython/core/display_functions.py +++ b/IPython/core/display_functions.py @@ -85,7 +85,17 @@ def _new_id(): return b2a_hex(os.urandom(16)).decode('ascii') -def display(*objs, include=None, exclude=None, metadata=None, transient=None, display_id=None, **kwargs): +def display( + *objs, + include=None, + exclude=None, + metadata=None, + transient=None, + display_id=None, + raw=False, + clear=False, + **kwargs +): """Display a Python object in all frontends. By default all representations will be computed and sent to the frontends. @@ -242,8 +252,6 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di print(*objs) return - raw = kwargs.pop("raw", False) - clear = kwargs.pop("clear", False) if transient is None: transient = {} if metadata is None: diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 03b76cb..6dc0ad3 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -636,7 +636,7 @@ class Magics(Configurable): '%s ( allowed: "%s" %s)' % (e.msg, opt_str, " ".join(long_opts)) ) from e for o, a in opts: - if mode is "string" and preserve_non_opts: + if mode == "string" and preserve_non_opts: # remove option-parts from the original args-string and preserve remaining-part. # This relies on the arg_split(...) and getopt(...)'s impl spec, that the parsed options are # returned in the original order. diff --git a/IPython/terminal/embed.py b/IPython/terminal/embed.py index 188844f..6c63d33 100644 --- a/IPython/terminal/embed.py +++ b/IPython/terminal/embed.py @@ -334,7 +334,7 @@ class InteractiveShellEmbed(TerminalInteractiveShell): self.compile.flags = orig_compile_flags -def embed(**kwargs): +def embed(*, header="", compile_flags=None, **kwargs): """Call this to embed IPython at the current point in your program. The first invocation of this will create an :class:`InteractiveShellEmbed` @@ -360,8 +360,6 @@ def embed(**kwargs): config argument. """ config = kwargs.get('config') - header = kwargs.pop('header', u'') - compile_flags = kwargs.pop('compile_flags', None) if config is None: config = load_default_config() config.InteractiveShellEmbed = config.TerminalInteractiveShell