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

Method predicted_indent

bpython/curtsiesfrontend/repl.py:1228–1245  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

1226 self.list_win_visible = self.complete(tab)
1227
1228 def predicted_indent(self, line):
1229 # TODO get rid of this! It's repeated code! Combine with Repl.
1230 logger.debug("line is %r", line)
1231 indent = len(re.match(r"[ ]*", line).group())
1232 if line.endswith(":"):
1233 indent = max(0, indent + self.config.tab_length)
1234 elif line and line.count(" ") == len(line):
1235 indent = max(0, indent - self.config.tab_length)
1236 elif (
1237 line
1238 and ":" not in line
1239 and line.strip().startswith(
1240 ("return", "pass", "...", "raise", "yield", "break", "continue")
1241 )
1242 ):
1243 indent = max(0, indent - self.config.tab_length)
1244 logger.debug("indent we found was %s", indent)
1245 return indent
1246
1247 def push(self, line, insert_into_history=True) -> bool:
1248 """Push a line of code onto the buffer, start running the buffer

Callers 4

pushMethod · 0.95
take_back_buffer_lineMethod · 0.95
test_simpleMethod · 0.80
test_complexMethod · 0.80

Calls 1

matchMethod · 0.80

Tested by 2

test_simpleMethod · 0.64
test_complexMethod · 0.64