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

Function next_indentation

bpython/repl.py:1258–1269  ·  view source on GitHub ↗

Given a code line, return the indentation of the next line.

(line, tab_length)

Source from the content-addressed store, hash-verified

1256
1257
1258def next_indentation(line, tab_length) -> int:
1259 """Given a code line, return the indentation of the next line."""
1260 line = line.expandtabs(tab_length)
1261 indentation: int = (len(line) - len(line.lstrip(" "))) // tab_length
1262 if line.rstrip().endswith(":"):
1263 indentation += 1
1264 elif indentation >= 1:
1265 if line.lstrip().startswith(
1266 ("return", "pass", "...", "raise", "yield", "break", "continue")
1267 ):
1268 indentation -= 1
1269 return indentation
1270
1271
1272def split_lines(tokens):

Callers 1

next_indentationMethod · 0.85

Calls 1

expandtabsMethod · 0.80

Tested by

no test coverage detected