Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: leading whitespace (#4774)

Dylan Madisetti792046ca721b
diff --git a/marimo/_ast/codegen.py b/marimo/_ast/codegen.py
index a66245e02f..85caedea0f 100644
--- a/marimo/_ast/codegen.py
+++ b/marimo/_ast/codegen.py
@@ -395,7 +395,7 @@ def generate_filecontents(
"",
]
)
- return "\n".join(filecontents)
+ return "\n".join(filecontents).lstrip()
def recover(filename: str) -> str:
diff --git a/tests/_ast/test_codegen.py b/tests/_ast/test_codegen.py
index aac8ec5c18..7f5e362539 100644
--- a/tests/_ast/test_codegen.py
+++ b/tests/_ast/test_codegen.py
@@ -62,9 +62,12 @@ def wrap_generate_filecontents(
resolved_configs = [CellConfig() for _ in range(len(codes))]
else:
resolved_configs = cell_configs
- return codegen.generate_filecontents(
+ filecontents = codegen.generate_filecontents(
codes, names, cell_configs=resolved_configs, **kwargs
)
+ # leading spaces should be removed too
+ assert filecontents.lstrip() == filecontents
+ return filecontents
def get_idempotent_marimo_source(name: str) -> str: