From 479d000727520f1a1df46e47f48e59f5d20623bf 2018-03-13 09:09:49 From: Min RK Date: 2018-03-13 09:09:49 Subject: [PATCH] Backport PR #11044: Add shell.check_complete() method --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 542f4c9..ad8824b 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2900,6 +2900,26 @@ class InteractiveShell(SingletonConfigurable): # For backwards compatibility runcode = run_code + def check_complete(self, code): + """Return whether a block of code is ready to execute, or should be continued + + Parameters + ---------- + source : string + Python input code, which can be multiline. + + Returns + ------- + status : str + One of 'complete', 'incomplete', or 'invalid' if source is not a + prefix of valid code. + indent : str + When status is 'incomplete', this is some whitespace to insert on + the next line of the prompt. + """ + status, nspaces = self.input_splitter.check_complete(code) + return status, ' ' * (nspaces or 0) + #------------------------------------------------------------------------- # Things related to GUI support and pylab #-------------------------------------------------------------------------