MCPcopy
hub / github.com/marimo-team/marimo / fixed_dedent

Function fixed_dedent

marimo/_ast/parse.py:67–84  ·  view source on GitHub ↗

Manually edited code, can dedent

(text: str)

Source from the content-addressed store, hash-verified

65
66
67def fixed_dedent(text: str) -> str:
68 """Manually edited code, can dedent"""
69 # Added robustness for AI generated code
70 lines = text.splitlines()
71 for line in lines:
72 if content := line.lstrip():
73 indent = line[: len(line) - len(content)]
74 break
75 else:
76 # Quit early, no clear leading spaces
77 return dedent(text)
78
79 def refill(line: str) -> str:
80 if not line.startswith(indent):
81 return indent + line
82 return line
83
84 return dedent("\n".join(map(refill, lines)))
85
86
87def unwrap_cell_body(formatted: str) -> str:

Callers 7

_extract_body_codeFunction · 0.90
test_fixed_dedentFunction · 0.90
unwrap_cell_bodyFunction · 0.85
extract_from_codeMethod · 0.85
to_cell_defMethod · 0.85
to_cellMethod · 0.85

Calls 3

dedentFunction · 0.85
mapFunction · 0.85
joinMethod · 0.45

Tested by 1

test_fixed_dedentFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…