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: top level function serialization broke in wasm example (#3945)

Dylan Madisettibc7ae2e6a5a0
diff --git a/marimo/_ast/codegen.py b/marimo/_ast/codegen.py
index 4c03ebd0a6..69237ae487 100644
--- a/marimo/_ast/codegen.py
+++ b/marimo/_ast/codegen.py
@@ -130,10 +130,14 @@ def build_import_section(import_blocks: list[str]) -> str:
formatted = Formatter(MAX_LINE_LENGTH).format({stub_cell_id: code})
if not formatted:
return code
- tidied = ruff(formatted, "check", "--fix-only")
- if not tidied:
- return formatted[stub_cell_id]
- return tidied[stub_cell_id] + "\n\n"
+ try:
+ tidied = ruff(formatted, "check", "--fix-only")
+ if tidied:
+ return tidied[stub_cell_id] + "\n\n"
+ # Thrown in WASM
+ except OSError:
+ pass
+ return formatted[stub_cell_id]
def to_functiondef(