MCPcopy Create free account
hub / github.com/ipython/ipython / check_complete

Method check_complete

IPython/core/inputsplitter.py:352–386  ·  view source on GitHub ↗

Return whether a block of code is ready to execute, or should be continued This is a non-stateful API, and will reset the state of this InputSplitter. Parameters ---------- source : string Python input code, which can be multiline.

(self, source)

Source from the content-addressed store, hash-verified

350 return out
351
352 def check_complete(self, source):
353 """Return whether a block of code is ready to execute, or should be continued
354
355 This is a non-stateful API, and will reset the state of this InputSplitter.
356
357 Parameters
358 ----------
359 source : string
360 Python input code, which can be multiline.
361
362 Returns
363 -------
364 status : str
365 One of 'complete', 'incomplete', or 'invalid' if source is not a
366 prefix of valid code.
367 indent_spaces : int or None
368 The number of spaces by which to indent the next line of code. If
369 status is not 'incomplete', this is None.
370 """
371 self.reset()
372 try:
373 self.push(source)
374 except SyntaxError:
375 # Transformers in IPythonInputSplitter can raise SyntaxError,
376 # which push() will not catch.
377 return 'invalid', None
378 else:
379 if self._is_invalid:
380 return 'invalid', None
381 elif self.push_accepts_more():
382 return 'incomplete', self.get_indent_spaces()
383 else:
384 return 'complete', None
385 finally:
386 self.reset()
387
388 def push(self, lines:str) -> bool:
389 """Push one or more lines of input.

Callers 4

newline_or_executeFunction · 0.45
newline_autoindentFunction · 0.45
promptMethod · 0.45
test_check_completeMethod · 0.45

Calls 4

resetMethod · 0.95
pushMethod · 0.95
push_accepts_moreMethod · 0.95
get_indent_spacesMethod · 0.95

Tested by 1

test_check_completeMethod · 0.36