MCPcopy Index your code
hub / github.com/bpython/bpython / code_finished_will_parse

Function code_finished_will_parse

bpython/curtsiesfrontend/interpreter.py:123–136  ·  view source on GitHub ↗

Returns a tuple of whether the buffer could be complete and whether it will parse True, True means code block is finished and no predicted parse error True, False means code block is finished because a parse error is predicted False, True means code block is unfinished False, Fa

(
    s: str, compiler: CommandCompiler
)

Source from the content-addressed store, hash-verified

121
122
123def code_finished_will_parse(
124 s: str, compiler: CommandCompiler
125) -> tuple[bool, bool]:
126 """Returns a tuple of whether the buffer could be complete and whether it
127 will parse
128
129 True, True means code block is finished and no predicted parse error
130 True, False means code block is finished because a parse error is predicted
131 False, True means code block is unfinished
132 False, False isn't possible - an predicted error makes code block done"""
133 try:
134 return bool(compiler(s)), True
135 except (ValueError, SyntaxError, OverflowError):
136 return True, False

Callers 2

assertCompilesMethod · 0.90
pushMethod · 0.85

Calls

no outgoing calls

Tested by 1

assertCompilesMethod · 0.72