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.

chore: format tuple in return to match ruff/black (#2351)

Akshay Agrawal515eef3e8b84
diff --git a/marimo/_ast/codegen.py b/marimo/_ast/codegen.py
index e1076687b3..b453f1fde3 100644
--- a/marimo/_ast/codegen.py
+++ b/marimo/_ast/codegen.py
@@ -85,7 +85,7 @@ def to_functiondef(
defs = tuple(name for name in sorted(cell.defs))
returns = INDENT + "return "
if len(cell.defs) == 1:
- returns += f"{defs[0]},"
+ returns += f"({defs[0]},)"
else:
returns += ", ".join(defs)
fndef += (
diff --git a/tests/_ast/codegen_data/test_generate_filecontents.py b/tests/_ast/codegen_data/test_generate_filecontents.py
index ab9ff4a08b..83f26134f3 100644
--- a/tests/_ast/codegen_data/test_generate_filecontents.py
+++ b/tests/_ast/codegen_data/test_generate_filecontents.py
@@ -7,7 +7,7 @@ app = marimo.App()
@app.cell
def one():
import numpy as np
- return np,
+ return (np,)
@app.cell
@@ -20,14 +20,14 @@ def two():
@app.cell
def three(x):
y = x + 1
- return y,
+ return (y,)
@app.cell
def four(np, x, y):
# comment
z = np.array(x + y)
- return z,
+ return (z,)
@app.cell
diff --git a/tests/_ast/codegen_data/test_generate_filecontents_async_long_signature.py b/tests/_ast/codegen_data/test_generate_filecontents_async_long_signature.py
index 0a5f17f47b..d4c49fec89 100644
--- a/tests/_ast/codegen_data/test_generate_filecontents_async_long_signature.py
+++ b/tests/_ast/codegen_data/test_generate_filecontents_async_long_signature.py
@@ -40,7 +40,7 @@ async def two(
async for data_point in client("test", "ws://localhost:8000"):
print(data_point)
data_point
- return data_point,
+ return (data_point,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_generate_filecontents_shadowed_builtin.py b/tests/_ast/codegen_data/test_generate_filecontents_shadowed_builtin.py
index c695f781fd..f0afa25b6a 100644
--- a/tests/_ast/codegen_data/test_generate_filecontents_shadowed_builtin.py
+++ b/tests/_ast/codegen_data/test_generate_filecontents_shadowed_builtin.py
@@ -7,7 +7,7 @@ app = marimo.App()
@app.cell
def one():
type = 1
- return type,
+ return (type,)
@app.cell
diff --git a/tests/_ast/codegen_data/test_generate_filecontents_single_cell.py b/tests/_ast/codegen_data/test_generate_filecontents_single_cell.py
index ab2ef8bf45..0152a08112 100644
--- a/tests/_ast/codegen_data/test_generate_filecontents_single_cell.py
+++ b/tests/_ast/codegen_data/test_generate_filecontents_single_cell.py
@@ -7,7 +7,7 @@ app = marimo.App()
@app.cell
def one():
import numpy as np
- return np,
+ return (np,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_generate_filecontents_with_syntax_error.py b/tests/_ast/codegen_data/test_generate_filecontents_with_syntax_error.py
index aff6f1104c..3c6994a7e3 100644
--- a/tests/_ast/codegen_data/test_generate_filecontents_with_syntax_error.py
+++ b/tests/_ast/codegen_data/test_generate_filecontents_with_syntax_error.py
@@ -7,7 +7,7 @@ app = marimo.App()
@app.cell
def one():
import numpy as np
- return np,
+ return (np,)
app._unparsable_cell(
diff --git a/tests/_ast/codegen_data/test_get_codes_messy.py b/tests/_ast/codegen_data/test_get_codes_messy.py
index e4b5a170ef..f00da166ea 100644
--- a/tests/_ast/codegen_data/test_get_codes_messy.py
+++ b/tests/_ast/codegen_data/test_get_codes_messy.py
@@ -14,7 +14,7 @@ def __(a,
# yet another comment
x = 0 + a + b + c + d
- return x,
+ return (x,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_get_codes_multiline_fndef.py b/tests/_ast/codegen_data/test_get_codes_multiline_fndef.py
index 5cca0678c9..5943f867a7 100644
--- a/tests/_ast/codegen_data/test_get_codes_multiline_fndef.py
+++ b/tests/_ast/codegen_data/test_get_codes_multiline_fndef.py
@@ -9,7 +9,7 @@ def one(a,
b, c,d) -> int:
# comment
x = 0 + a + b + c + d
- return x,
+ return (x,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_get_codes_multiline_string.py b/tests/_ast/codegen_data/test_get_codes_multiline_string.py
index b0aae4fea3..d3d9b05193 100644
--- a/tests/_ast/codegen_data/test_get_codes_multiline_string.py
+++ b/tests/_ast/codegen_data/test_get_codes_multiline_string.py
@@ -6,7 +6,7 @@ app = marimo.App()
@app.cell
def one(): c = """
- a, b"""; return c,
+ a, b"""; return (c,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_get_codes_single_line_fn.py b/tests/_ast/codegen_data/test_get_codes_single_line_fn.py
index 3b88fe13b1..10ab2db776 100644
--- a/tests/_ast/codegen_data/test_get_codes_single_line_fn.py
+++ b/tests/_ast/codegen_data/test_get_codes_single_line_fn.py
@@ -5,7 +5,7 @@ app = marimo.App()
@app.cell
-def one(a: int, b: int) -> None: c = a + b; print(c); return c,
+def one(a: int, b: int) -> None: c = a + b; print(c); return (c,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_get_codes_with_incorrect_args_rets.py b/tests/_ast/codegen_data/test_get_codes_with_incorrect_args_rets.py
index a20bc5553f..6d49c7131a 100644
--- a/tests/_ast/codegen_data/test_get_codes_with_incorrect_args_rets.py
+++ b/tests/_ast/codegen_data/test_get_codes_with_incorrect_args_rets.py
@@ -13,7 +13,7 @@ def one():
def two():
x = 0
xx = 1
- return x,
+ return (x,)
@app.cell
@@ -25,7 +25,7 @@ def three():
def four(y):
# comment
z = np.array(x + y)
- return z,
+ return (z,)
@app.cell
diff --git a/tests/_ast/codegen_data/test_long_line_in_main.py b/tests/_ast/codegen_data/test_long_line_in_main.py
index 89d36247a4..823da962c9 100644
--- a/tests/_ast/codegen_data/test_long_line_in_main.py
+++ b/tests/_ast/codegen_data/test_long_line_in_main.py
@@ -23,7 +23,7 @@ def two(
yet_another_very_long_name,
):
z = i_am_a_very_long_name + i_am_another_very_long_name + yet_another_very_long_name
- return z,
+ return (z,)
if __name__ == "__main__":
diff --git a/tests/_ast/codegen_data/test_main.py b/tests/_ast/codegen_data/test_main.py
index ddf3b5835c..f3c34f92c5 100644
--- a/tests/_ast/codegen_data/test_main.py
+++ b/tests/_ast/codegen_data/test_main.py
@@ -9,21 +9,21 @@ app = marimo.App()
@app.cell
def one() -> Tuple[Any]:
x = 0
- return x,
+ return (x,)
@app.cell
def two(x: Any) -> Tuple[Any, Any]:
y = x + 1
z = y + 1
- 'z'
+ "z"
return y, z
@app.cell
def three(x: Any, y: Any) -> Tuple[Any]:
a = x + y
- return a,
+ return (a,)
if __name__ == "__main__":
diff --git a/tests/_ast/test_codegen.py b/tests/_ast/test_codegen.py
index c55b89df54..2b684d70c5 100644
--- a/tests/_ast/test_codegen.py
+++ b/tests/_ast/test_codegen.py
@@ -431,7 +431,7 @@ class TestToFunctionDef:
cell = compile_cell(code)
fndef = codegen.to_functiondef(cell, "foo")
expected = "\n".join(
- ["@app.cell", "def foo():", " x = 0", " return x,"]
+ ["@app.cell", "def foo():", " x = 0", " return (x,)"]
)
assert fndef == expected
@@ -491,7 +491,7 @@ class TestToFunctionDef:
cell = cell.configure(CellConfig())
fndef = codegen.to_functiondef(cell, "foo")
expected = "\n".join(
- ["@app.cell", "def foo():", " x = 0", " return x,"]
+ ["@app.cell", "def foo():", " x = 0", " return (x,)"]
)
assert fndef == expected
@@ -505,7 +505,7 @@ class TestToFunctionDef:
"@app.cell(disabled=True)",
"def foo():",
" x = 0",
- " return x,",
+ " return (x,)",
]
)
assert fndef == expected
@@ -520,7 +520,7 @@ class TestToFunctionDef:
"@app.cell(disabled=True, hide_code=True)",
"def foo():",
" x = 0",
- " return x,",
+ " return (x,)",
]
)
assert fndef == expected
@@ -535,7 +535,7 @@ class TestToFunctionDef:
"@app.cell",
"def foo():",
" x = 0",
- " return x,",
+ " return (x,)",
]
)
assert fndef == expected
diff --git a/tests/_cli/snapshots/unsafe-app.py.txt b/tests/_cli/snapshots/unsafe-app.py.txt
index 427c1d8a05..279b3102e8 100644
--- a/tests/_cli/snapshots/unsafe-app.py.txt
+++ b/tests/_cli/snapshots/unsafe-app.py.txt
@@ -7,7 +7,7 @@ app = marimo.App(app_title="Test Notebook")
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
@app.cell
diff --git a/tests/_server/test_file_manager.py b/tests/_server/test_file_manager.py
index b06060900e..75c95716a7 100644
--- a/tests/_server/test_file_manager.py
+++ b/tests/_server/test_file_manager.py
@@ -241,7 +241,7 @@ def test_to_code(app_file_manager: AppFileManager) -> None:
"@app.cell",
"def __():",
" import marimo as mo",
- " return mo,",
+ " return (mo,)",
"",
"",
'if __name__ == "__main__":',