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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
feat: release reusable functions (#4560)
Dylan Madisettibeea536a99a9
diff --git a/frontend/src/components/app-config/user-config-form.tsx b/frontend/src/components/app-config/user-config-form.tsxindex bee919bfa9..39067feef6 100644--- a/frontend/src/components/app-config/user-config-form.tsx+++ b/frontend/src/components/app-config/user-config-form.tsx@@ -1349,31 +1349,6 @@ export const UserConfigForm: React.FC = () => {</div>)}/>- <FormField- control={form.control}- name="experimental.toplevel_defs"- render={({ field }) => (- <div className="flex flex-col gap-y-1">- <FormItem className={formItemClasses}>- <FormLabel className="font-normal">- Library Save Format- </FormLabel>- <FormControl>- <Checkbox- data-testid="toplevel-defs-checkbox"- checked={field.value === true}- onCheckedChange={field.onChange}- />- </FormControl>- </FormItem>- <FormDescription>- Enable saving in an experimental file format for marimo.- This will expose functions that are defined in their own- cell for function reuse and import by other programs.- </FormDescription>{" "}- </div>- )}- /><FormFieldcontrol={form.control}name="experimental.table_charts"diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsxindex 938656dc15..e71ee0d96a 100644--- a/frontend/src/components/editor/actions/useNotebookActions.tsx+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx@@ -85,7 +85,6 @@ import { AddDatabaseDialogContent } from "../database/add-database-form";import { useHideAllMarkdownCode } from "./useHideAllMarkdownCode";import { useSectionCollapse } from "./useSectionCollapse";import { Constants } from "@/core/constants";-import { getFeatureFlag } from "@/core/config/feature-flag";const NOOP_HANDLER = (event?: Event) => {event?.preventDefault();@@ -392,7 +391,6 @@ export function useNotebookActions() {{icon: <DiamondPlusIcon size={14} strokeWidth={1.5} />,label: "Add setup cell",- hidden: !getFeatureFlag("toplevel_defs"),handle: () => {upsertSetupCell({code: "# Initialization code that runs before all other cells",diff --git a/frontend/src/core/config/feature-flag.tsx b/frontend/src/core/config/feature-flag.tsxindex b28ef0249e..142ebdf0d7 100644--- a/frontend/src/core/config/feature-flag.tsx+++ b/frontend/src/core/config/feature-flag.tsx@@ -13,7 +13,6 @@ export interface ExperimentalFeatures {scratchpad: boolean;rtc_v2: boolean;reactive_tests: boolean;- toplevel_defs: boolean;table_charts: boolean;// Add new feature flags here}@@ -25,7 +24,6 @@ const defaultValues: ExperimentalFeatures = {scratchpad: true,rtc_v2: false,reactive_tests: false,- toplevel_defs: false,table_charts: false,};diff --git a/marimo/_ast/codegen.py b/marimo/_ast/codegen.pyindex 1c0b465858..f81d926e59 100644--- a/marimo/_ast/codegen.py+++ b/marimo/_ast/codegen.py@@ -17,7 +17,6 @@ from marimo._ast.compiler import compile_cellfrom marimo._ast.names import DEFAULT_CELL_NAME, SETUP_CELL_NAMEfrom marimo._ast.toplevel import TopLevelExtraction, TopLevelStatusfrom marimo._ast.visitor import Name-from marimo._config.manager import get_default_config_managerfrom marimo._types.ids import CellId_tif sys.version_info < (3, 10):@@ -44,10 +43,9 @@ def pop_setup_cell(code: list[str],names: list[str],configs: list[CellConfig],- toplevel_fn: bool,) -> Optional[CellImpl]:# Find the cell named setup, compile, and remove the index from all lists.- if SETUP_CELL_NAME not in names or not toplevel_fn:+ if SETUP_CELL_NAME not in names:return Nonesetup_index = names.index(SETUP_CELL_NAME)try:@@ -267,7 +265,7 @@ def generate_unparsable_cell(def serialize_cell(- extraction: TopLevelExtraction, status: TopLevelStatus, toplevel_fn: bool+ extraction: TopLevelExtraction, status: TopLevelStatus) -> str:if status.is_unparsable:return generate_unparsable_cell(@@ -275,11 +273,7 @@ def serialize_cell()cell = status._cellassert cell is not None- if not toplevel_fn:- return to_functiondef(- cell, status.name, extraction.unshadowed, None, fn="cell"- )- elif status.is_cell:+ if status.is_cell:return to_functiondef(cell,status.name,@@ -313,66 +307,25 @@ def generate_app_constructor(config: Optional[_AppConfig]) -> str:return format_tuple_elements("app = marimo.App(...)", kwargs)-def _classic_export(- fndefs: list[str],- header_comments: Optional[str],- config: Optional[_AppConfig],-) -> str:- filecontents = "".join(- "import marimo"- + "\n\n"- + f'__generated_with = "{__version__}"'- + "\n"- + generate_app_constructor(config)- + "\n\n\n"- + "\n\n\n".join(fndefs)- + "\n\n\n"- + 'if __name__ == "__main__":'- + "\n"- + indent_text("app.run()")- )-- if header_comments:- filecontents = header_comments.rstrip() + "\n\n" + filecontents- return filecontents + "\n"--def generate_filecontents(codes: list[str],names: list[str],cell_configs: list[CellConfig],config: Optional[_AppConfig] = None,header_comments: Optional[str] = None,- _toplevel_fn: bool = False,) -> str:"""Translates a sequences of codes (cells) to a Python file"""- # Until an appropriate means of controlling top-level functions exists,- # Let's keep it disabled by default.- toplevel_fn = (- get_default_config_manager(current_path=None)- .get_config()- .get("experimental", {})- .get("toplevel_defs", False)- ) or _toplevel_fn-# Update old internal cell names to the new onesfor idx, name in enumerate(names):if name == "__":names[idx] = DEFAULT_CELL_NAME- # TODO: replace with dedicated cell- setup_cell = pop_setup_cell(codes, names, cell_configs, toplevel_fn)+ setup_cell = pop_setup_cell(codes, names, cell_configs)toplevel_defs: set[Name] = set()if setup_cell:toplevel_defs = set(setup_cell.defs)extraction = TopLevelExtraction(codes, names, cell_configs, toplevel_defs)- cell_blocks = [- serialize_cell(extraction, status, toplevel_fn)- for status in extraction- ]-- if not toplevel_fn:- return _classic_export(cell_blocks, header_comments, config)+ cell_blocks = [serialize_cell(extraction, status) for status in extraction]filecontents = []if header_comments is not None:diff --git a/marimo/_ast/toplevel.py b/marimo/_ast/toplevel.pyindex e5bf273dc8..d8fe1c3953 100644--- a/marimo/_ast/toplevel.py+++ b/marimo/_ast/toplevel.py@@ -387,7 +387,7 @@ class TopLevelExtraction:from marimo._ast.codegen import pop_setup_cell- setup = pop_setup_cell(codes, names, cell_configs, True)+ setup = pop_setup_cell(codes, names, cell_configs)if setup:return cls(codes, names, cell_configs, setup.defs)return cls(codes, names, cell_configs, set())diff --git a/marimo/_runtime/runner/hooks_post_execution.py b/marimo/_runtime/runner/hooks_post_execution.pyindex 0a04336b2a..6c9fdce99d 100644--- a/marimo/_runtime/runner/hooks_post_execution.py+++ b/marimo/_runtime/runner/hooks_post_execution.py@@ -330,7 +330,7 @@ def _broadcast_outputs(@kernel_tracer.start_as_current_span("render_toplevel_defs")-def _render_toplevel_defs(+def render_toplevel_defs(cell: CellImpl,runner: cell_runner.Runner,run_result: cell_runner.RunResult,@@ -347,7 +347,7 @@ def _render_toplevel_defs(@kernel_tracer.start_as_current_span("run_pytest")-def _attempt_pytest(+def attempt_pytest(cell: CellImpl,runner: cell_runner.Runner,run_result: cell_runner.RunResult,@@ -402,4 +402,6 @@ POST_EXECUTION_HOOKS: list[PostExecutionHookType] = [# other hooks take a long time (broadcast outputs can take a long time# if a formatter is slow)._set_status_idle,+ # NB. Other hooks are added ad-hoc or manually due to priority.+ # Consider implementing priority sort to keep everything more centralized.]diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex 6b9c9c4781..12e1eb419d 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -136,7 +136,10 @@ from marimo._runtime.runner.hooks import (PREPARATION_HOOKS,)from marimo._runtime.runner.hooks_on_finish import OnFinishHookType-from marimo._runtime.runner.hooks_post_execution import PostExecutionHookType+from marimo._runtime.runner.hooks_post_execution import (+ PostExecutionHookType,+ render_toplevel_defs,+)from marimo._runtime.runner.hooks_pre_execution import PreExecutionHookTypefrom marimo._runtime.runner.hooks_preparation import PreparationHookTypefrom marimo._runtime.scratch import SCRATCH_CELL_ID@@ -518,18 +521,13 @@ class Kernel:# Adds in a post_execution hook to run pytest immediatelyif user_config["runtime"].get("reactive_tests", False):from marimo._runtime.runner.hooks_post_execution import (- _attempt_pytest,+ attempt_pytest,)- self._post_execution_hooks.append(_attempt_pytest)-- # Adds in a post_execution hook to run pytest immediately- if user_config.get("experimental", {}).get("toplevel_defs", False):- from marimo._runtime.runner.hooks_post_execution import (- _render_toplevel_defs,- )+ self._post_execution_hooks.append(attempt_pytest)- self._post_execution_hooks.append(_render_toplevel_defs)+ # Must be last to properly trigger render.+ self._post_execution_hooks.append(render_toplevel_defs)self._globals_lock = threading.RLock()self._completion_worker_started = Falsediff --git a/marimo/_server/print.py b/marimo/_server/print.pyindex bde1384152..e49b047516 100644--- a/marimo/_server/print.py+++ b/marimo/_server/print.py@@ -120,6 +120,7 @@ def print_experimental_features(config: MarimoConfig) -> None:"sql_engines","secrets","reactive_tests",+ "toplevel_defs",}keys = keys - finished_experimentsdiff --git a/marimo/_tutorials/dataflow.py b/marimo/_tutorials/dataflow.pyindex 57c5ac15d9..7a0ed7b460 100644--- a/marimo/_tutorials/dataflow.py+++ b/marimo/_tutorials/dataflow.py@@ -10,7 +10,7 @@import marimo-__generated_with = "0.12.2"+__generated_with = "0.12.10"app = marimo.App()@@ -259,14 +259,14 @@ def _(mo):def _():planet = "Mars"planet- return (planet,)+ return@app.celldef _():planet = "Earth"planet- return (planet,)+ return@app.cell(hide_code=True)@@ -298,13 +298,13 @@ def _(mo):@app.celldef _():count = 0- return (count,)+ return@app.celldef _():count += 1- return (count,)+ return@app.cell(hide_code=True)@@ -439,7 +439,7 @@ def _():state = namespace()state.number = 0- return namespace, state+ return (state,)@app.cell(hide_code=True)diff --git a/marimo/_tutorials/for_jupyter_users.py b/marimo/_tutorials/for_jupyter_users.pyindex ac5ea34081..07f4f352e9 100644--- a/marimo/_tutorials/for_jupyter_users.py+++ b/marimo/_tutorials/for_jupyter_users.py@@ -2,12 +2,12 @@import marimo-__generated_with = "0.9.30"+__generated_with = "0.12.10"app = marimo.App(app_title="marimo for Jupyter users")@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""# marimo for Jupyter users@@ -20,7 +20,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Reactive execution@@ -34,19 +34,19 @@ def __(mo):@app.cell-def __():+def _():x = 0; xreturn (x,)@app.cell-def __(x):+def _(x):y = x + 1; y- return (y,)+ return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""marimo 'reacts' to the change in `x` and automatically recalculates `y`!@@ -63,7 +63,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""### Why?@@ -83,7 +83,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## Interactive elements built-in@@ -96,26 +96,26 @@ def __(mo):@app.cell-def __():+def _():import marimo as moreturn (mo,)@app.cell-def __(mo):+def _(mo):slider = mo.ui.slider(start=1, stop=10, label="$x$")sliderreturn (slider,)@app.cell-def __(slider):+def _(slider):slider.valuereturn@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(rf"""**Explanation.** marimo is both a notebook and a library. Import `marimo as@@ -132,7 +132,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Shareable as apps@@ -152,7 +152,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Cell order@@ -164,19 +164,19 @@ def __(mo):@app.cell-def __(z):+def _(z):z.valuereturn@app.cell-def __(mo):+def _(mo):z = mo.ui.slider(1, 10, label="$z$"); zreturn (z,)@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""This lets you arrange your cells in the way that makes the most sense to you. For example, put helper functions and imports at the bottom of a notebook, like an appendix.@@ -188,7 +188,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Re-assigning variables@@ -200,25 +200,25 @@ def __(mo):@app.cell-def __():+def _():df = 0return (df,)@app.cell-def __():+def _():df = 1return (df,)@app.cell-def __(df):+def _(df):results = df.groupby(["my_column"]).sum()- return (results,)+ return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""**Explanation.** `results` depends on `df`, but which value of `df` should it use? Reactivity makes it impossible to answer this question in a sensible way, so marimo disallows variable reassignment.@@ -234,7 +234,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(rf"""## Markdown@@ -246,7 +246,7 @@ def __(mo):@app.cell-def __(mo, slider):+def _(mo, slider):mo.md(f"""The value of {slider} is {slider.value}.@@ -256,7 +256,7 @@ def __(mo, slider):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""**Explanation.** By lifting Markdown into Python, marimo lets you construct@@ -271,7 +271,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Notebook files@@ -293,7 +293,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""## Parting thoughtsdiff --git a/marimo/_tutorials/intro.py b/marimo/_tutorials/intro.pyindex 0eb9e7c529..c4ca31a295 100644--- a/marimo/_tutorials/intro.py+++ b/marimo/_tutorials/intro.py@@ -2,12 +2,12 @@import marimo-__generated_with = "0.9.2"+__generated_with = "0.12.10"app = marimo.App()@app.cell-def __():+def _():import marimo as momo.md("# Welcome to marimo! 🌊🍃")@@ -15,13 +15,13 @@ def __():@app.cell-def __(mo):+def _(mo):slider = mo.ui.slider(1, 22)return (slider,)@app.cell-def __(mo, slider):+def _(mo, slider):mo.md(f"""marimo is a **reactive** Python notebook.@@ -37,7 +37,7 @@ def __(mo, slider):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: disabling automatic execution": mo.md(@@ -59,7 +59,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""Tip: This is a tutorial notebook. You can create your own notebooks@@ -70,7 +70,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## 1. Reactive execution@@ -91,7 +91,7 @@ def __(mo):@app.cell(hide_code=True)-def __(changed, mo):+def _(changed, mo):(mo.md(f"""@@ -118,13 +118,13 @@ def __(changed, mo):@app.cell-def __():+def _():changed = Falsereturn (changed,)@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: execution order": (@@ -142,7 +142,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""**Global names must be unique.** To enable reactivity, marimo imposes a@@ -154,7 +154,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: encapsulation": (@@ -169,7 +169,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Tip: private variables": (@@ -184,7 +184,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## 2. UI elements@@ -202,37 +202,37 @@ def __(mo):@app.cell-def __(mo):+def _(mo):mo.md("""**🌊 Some UI elements.** Try interacting with the below elements.""")return@app.cell-def __(mo):+def _(mo):icon = mo.ui.dropdown(["🍃", "🌊", "✨"], value="🍃")return (icon,)@app.cell-def __(icon, mo):+def _(icon, mo):repetitions = mo.ui.slider(1, 16, label=f"number of {icon.value}: ")return (repetitions,)@app.cell-def __(icon, repetitions):+def _(icon, repetitions):icon, repetitionsreturn@app.cell-def __(icon, mo, repetitions):+def _(icon, mo, repetitions):mo.md("# " + icon.value * repetitions.value)return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## 3. marimo is just Python@@ -255,7 +255,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## 4. Running notebooks as apps@@ -272,7 +272,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## 5. The `marimo` command-line tool@@ -330,7 +330,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## 6. The marimo editor@@ -342,19 +342,19 @@ def __(mo):@app.cell-def __(mo, tips):+def _(mo, tips):mo.accordion(tips)return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## Finally, a fun fact""")return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""The name "marimo" is a reference to a type of algae that, under@@ -367,7 +367,7 @@ def __(mo):@app.cell(hide_code=True)-def __():+def _():tips = {"Saving": ("""diff --git a/marimo/_tutorials/layout.py b/marimo/_tutorials/layout.pyindex df8671bacf..bcdce2fddd 100644--- a/marimo/_tutorials/layout.py+++ b/marimo/_tutorials/layout.py@@ -2,12 +2,12 @@import marimo-__generated_with = "0.9.30"+__generated_with = "0.12.10"app = marimo.App()@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""# Layout@@ -20,7 +20,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## Rows and columns@@ -32,7 +32,7 @@ def __(mo):@app.cell-def __(mo):+def _(mo):mo.hstack([mo.ui.text(label="hello"), mo.ui.slider(1, 10, label="slider")],justify="start",@@ -41,13 +41,13 @@ def __(mo):@app.cell-def __(mo):+def _(mo):mo.vstack([mo.ui.text(label="world"), mo.ui.number(1, 10, label="number")])return@app.cell-def __(mo):+def _(mo):grid = mo.vstack([mo.hstack(@@ -69,11 +69,11 @@ def __(mo):plots!).""")- return (grid,)+ return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""**Customization.**@@ -85,7 +85,7 @@ def __(mo):@app.cell-def __(mo):+def _(mo):justify = mo.ui.dropdown(["start", "center", "end", "space-between", "space-around"],value="space-between",@@ -102,14 +102,14 @@ def __(mo):@app.cell-def __(mo):+def _(mo):size = mo.ui.slider(label="box size", start=60, stop=500)mo.hstack([size], justify="center")return (size,)@app.cell-def __(align, boxes, gap, justify, mo, wrap):+def _(align, boxes, gap, justify, mo, wrap):mo.hstack(boxes,align=align.value,@@ -121,7 +121,7 @@ def __(align, boxes, gap, justify, mo, wrap):@app.cell-def __(align, boxes, gap, mo):+def _(align, boxes, gap, mo):mo.vstack(boxes,align=align.value,@@ -131,7 +131,7 @@ def __(align, boxes, gap, mo):@app.cell-def __(mo, size):+def _(mo, size):def create_box(num=1):box_size = size.value + num * 10return mo.Html(@@ -140,11 +140,11 @@ def __(mo, size):boxes = [create_box(i) for i in range(1, 5)]- return boxes, create_box+ return (boxes,)@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Documentation: `mo.hstack`": mo.doc(mo.hstack),@@ -155,7 +155,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""**Justifying `Html`.** While you can center or right-justify any object@@ -168,25 +168,25 @@ def __(mo):@app.cell-def __(mo):+def _(mo):mo.md("""This markdown is left-justified.""")return@app.cell-def __(mo):+def _(mo):mo.md("This markdown is centered.").center()return@app.cell-def __(mo):+def _(mo):mo.md("This markdown is right-justified.").right()return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Documentation: `Html.center`": mo.doc(mo.Html.center),@@ -198,7 +198,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## Accordion@@ -210,13 +210,13 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""An accordion can contain multiple items:""")return@app.cell-def __(mo):+def _(mo):mo.accordion({"Multiple items": "By default, only one item can be open at a time",@@ -232,7 +232,7 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## Tabs@@ -244,7 +244,7 @@ def __(mo):@app.cell-def __(mo):+def _(mo):_settings = mo.vstack([mo.md("**Edit User**"),@@ -271,13 +271,13 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Documentation: `mo.ui.tabs`": mo.doc(mo.ui.tabs)})return@app.cell-def __(mo):+def _(mo):_t = [mo.md("**Hello!**"),mo.md(r"$f(x)$"),@@ -298,13 +298,13 @@ def __(mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Documentation: `mo.tree`": mo.doc(mo.tree)})return@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md("""## Callout@@ -317,7 +317,7 @@ def __(mo):@app.cell-def __(mo):+def _(mo):callout_kind = mo.ui.dropdown(["neutral", "warn", "success", "info", "danger"], value="neutral")@@ -325,7 +325,7 @@ def __(mo):@app.cell-def __(callout_kind, mo):+def _(callout_kind, mo):mo.md(f"""**This is a callout!**@@ -339,13 +339,13 @@ def __(callout_kind, mo):@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.accordion({"Documentation: `mo.callout`": mo.doc(mo.callout)})return@app.cell-def __():+def _():import marimo as moreturn (mo,)diff --git a/marimo/_tutorials/sql.py b/marimo/_tutorials/sql.pyindex 0dd5533b50..abfbf55526 100644--- a/marimo/_tutorials/sql.py+++ b/marimo/_tutorials/sql.py@@ -1,3 +1,4 @@+# Copyright 2025 Marimo. All rights reserved.# /// script# requires-python = ">=3.12"# dependencies = [@@ -12,7 +13,7 @@import marimo-__generated_with = "0.12.8"+__generated_with = "0.12.10"app = marimo.App(width="medium")@@ -69,14 +70,7 @@ def _():has_pandas_installed = Trueexcept ImportError:pass- return (- duckdb,- has_duckdb_installed,- has_pandas_installed,- has_polars_installed,- pandas,- polars,- )+ return has_duckdb_installed, has_polars_installed@app.cell(hide_code=True)@@ -206,7 +200,7 @@ def _(has_polars_installed):import pandas as pddf = pd.DataFrame(_data)- return df, pd, pl+ return (df,)@app.cell(hide_code=True)@@ -349,13 +343,7 @@ def _(mo, result, token_prefix):import plotly.graph_objects as goreturn go.Figure(data=[go.Histogram(x=result["count"])])- return (- render_altair,- render_chart,- render_charting_library,- render_matplotlib,- render_plotly,- )+ return (render_chart,)@app.cell(hide_code=True)@@ -388,7 +376,7 @@ def _(mo):@app.cell-def _(cars, mo):+def _(mo):cars = mo.sql(f"""-- Download a CSV and create an in-memory table; this is optional.@@ -450,7 +438,7 @@ def _(filtered_cars, mo):def _():import marimo as moimport random- return mo, random+ return (mo,)@app.cell(hide_code=True)diff --git a/marimo/_tutorials/ui.py b/marimo/_tutorials/ui.pyindex a414c0fa80..61268729bd 100644--- a/marimo/_tutorials/ui.py+++ b/marimo/_tutorials/ui.py@@ -2,7 +2,7 @@import marimo-__generated_with = "0.10.6"+__generated_with = "0.12.10"app = marimo.App()diff --git a/tests/_ast/codegen_data/test_generate_filecontents.py b/tests/_ast/codegen_data/test_generate_filecontents.pyindex 83f26134f3..5c22f50250 100644--- a/tests/_ast/codegen_data/test_generate_filecontents.py+++ b/tests/_ast/codegen_data/test_generate_filecontents.py@@ -14,7 +14,7 @@ def one():def two():x = 0xx = 1- return x, xx+ return (x,)@app.cell@@ -27,7 +27,7 @@ def three(x):def four(np, x, y):# commentz = np.array(x + y)- return (z,)+ return@app.celldiff --git a/tests/_ast/codegen_data/test_generate_filecontents_async.py b/tests/_ast/codegen_data/test_generate_filecontents_async.pyindex 20d6633c18..9b325a3bc0 100644--- a/tests/_ast/codegen_data/test_generate_filecontents_async.py+++ b/tests/_ast/codegen_data/test_generate_filecontents_async.py@@ -8,7 +8,7 @@ app = marimo.App()def one():import numpy as npimport asyncio- return asyncio, np+ return (asyncio,)@app.cell@@ -16,7 +16,7 @@ async def two(asyncio):x = 0xx = 1await asyncio.sleep(1)- return x, xx+ return (x,)@app.celldiff --git a/tests/_ast/codegen_data/test_generate_filecontents_async_long_signature.py b/tests/_ast/codegen_data/test_generate_filecontents_async_long_signature.pyindex d4c49fec89..55970d0843 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,)+ returnif __name__ == "__main__":diff --git a/tests/_ast/codegen_data/test_generate_filecontents_single_cell.py b/tests/_ast/codegen_data/test_generate_filecontents_single_cell.pyindex 0152a08112..c31ea72399 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.celldef one():import numpy as np- return (np,)+ returnif __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.pyindex 6a7972aade..56f41dba5a 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.celldef one():import numpy as np- return (np,)+ returnapp._unparsable_cell(diff --git a/tests/_ast/codegen_data/test_long_line_in_main.py b/tests/_ast/codegen_data/test_long_line_in_main.pyindex 823da962c9..3fb2e103c0 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,)+ returnif __name__ == "__main__":diff --git a/tests/_ast/test_codegen.py b/tests/_ast/test_codegen.pyindex 8016273f9a..2b2a34c57a 100644--- a/tests/_ast/test_codegen.py+++ b/tests/_ast/test_codegen.py@@ -79,7 +79,6 @@ def get_idempotent_marimo_source(name: str) -> str:list(app._cell_manager.configs()),app._config,header_comments,- _toplevel_fn=True,)generated_contents = sanitized_version(generated_contents)diff --git a/tests/_cli/snapshots/converted_multiple_defs.py.txt b/tests/_cli/snapshots/converted_multiple_defs.py.txtindex 1f1ea640ab..173443fdeb 100644--- a/tests/_cli/snapshots/converted_multiple_defs.py.txt+++ b/tests/_cli/snapshots/converted_multiple_defs.py.txt@@ -20,7 +20,7 @@ def _():@app.celldef _():y = 0- return (y,)+ return@app.celldiff --git a/tests/_convert/test_convert_utils.py b/tests/_convert/test_convert_utils.pyindex fcb724edb2..93906800a9 100644--- a/tests/_convert/test_convert_utils.py+++ b/tests/_convert/test_convert_utils.py@@ -46,7 +46,7 @@ def _():@app.celldef _():x = 5- return (x,)+ returnif __name__ == "__main__":@@ -79,7 +79,7 @@ def _():@app.celldef _():x = 5- return (x,)+ returnif __name__ == "__main__":diff --git a/tests/_server/test_file_manager.py b/tests/_server/test_file_manager.pyindex 603ae439d6..ad63161718 100644--- a/tests/_server/test_file_manager.py+++ b/tests/_server/test_file_manager.py@@ -246,7 +246,7 @@ def test_to_code(app_file_manager: AppFileManager) -> None:"@app.cell","def _():"," import marimo as mo",- " return (mo,)",+ " return","","",'if __name__ == "__main__":',