marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Last value should be in return statement

Open meghprkh opened this issue 7 months ago • 0 comments

Describe the bug

Whether a named value is returned or it is an "implicit" return renders the same but has very different behaviour

image

You can see that get_v are in sync but not get_v2

IMO the last value of the cell should be wrapped in __last__ = ... and returned so that the reactivity works more intuitively

Environment

{
        "marimo": "0.1.78",
        "OS": "Linux",
        "OS Version": "5.15.133.1-microsoft-standard-WSL2",
        "Processor": "x86_64",
        "Python Version": "3.12.1",
        "Binaries": {
                "Chrome": "--",
                "Node": "v21.1.0"
        },
        "Requirements": {
                "black": "23.12.1",
                "click": "8.1.7",
                "jedi": "0.19.1",
                "pymdown-extensions": "10.7",
                "tomlkit": "0.12.3",
                "tornado": "6.4",
                "typing_extensions": "4.9.0"
        }
}

Code to reproduce

import marimo
    
__generated_with = "0.1.78"
app = marimo.App()
    
    
@app.cell
def __():
                                import marimo as mo
                                return mo,
    
    
@app.cell
def __(mo):
                                get_v, set_v = mo.state(True)
                                get_v2, set_v2 = mo.state(True)
                                return get_v, get_v2, set_v, set_v2
    
    
@app.cell
def __(get_v, get_v2):
                                [get_v(), get_v2()]
                                return
    
    
@app.cell
def __(get_v, mo, set_v):
                                x = mo.ui.checkbox(get_v(), on_change=set_v)
                                x
                                return x,
    
    
@app.cell
def __(get_v, mo, set_v):
                                y = mo.ui.checkbox(get_v(), on_change=set_v)
                                y
                                return y,
    
    
@app.cell
def __(get_v2, mo, set_v2):
                                mo.ui.checkbox(get_v2(), on_change=set_v2)
                                return
    
    
@app.cell
def __(get_v2, mo, set_v2):
                                mo.ui.checkbox(get_v2(), on_change=set_v2)
                                return
    
    
if __name__ == "__main__":
                                app.run()
    

meghprkh avatar Jan 24 '24 18:01 meghprkh