Given a code line, return the indentation of the next line.
(line, tab_length)
| 1256 | |
| 1257 | |
| 1258 | def 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 | |
| 1272 | def split_lines(tokens): |
no test coverage detected