MCPcopy Index your code
hub / github.com/python/cpython / _get_previous_line_indent

Function _get_previous_line_indent

Lib/_pyrepl/readline.py:229–240  ·  view source on GitHub ↗
(buffer: list[str], pos: int)

Source from the content-addressed store, hash-verified

227
228
229def _get_previous_line_indent(buffer: list[str], pos: int) -> tuple[int, int | None]:
230 prevlinestart = pos
231 while prevlinestart > 0 and buffer[prevlinestart - 1] != "\n":
232 prevlinestart -= 1
233 prevlinetext = prevlinestart
234 while prevlinetext < pos and buffer[prevlinetext] in " \t":
235 prevlinetext += 1
236 if prevlinetext == pos:
237 indent = None
238 else:
239 indent = prevlinetext - prevlinestart
240 return prevlinestart, indent
241
242
243def _get_first_indentation(buffer: list[str]) -> str | None:

Callers 2

doMethod · 0.85
doMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…