Skip to content

Type issue with batch and slider elements #9163

@rambip

Description

@rambip

Describe the bug

I tried to use mo.md().batch() with sliders and numbers, and I get a type error with the default pyright config.

Type error:

Argument of type "slider" cannot be assigned to parameter "num_samples" of type "UIElement[JSONType, object]" in function "batch"
  "slider" is not assignable to "UIElement[JSONType, object]"
    Type parameter "S@UIElement" is invariant, but "Numeric" is not the same as "JSONType"
    Type parameter "T@UIElement" is invariant, but "Numeric" is not the same as "object"

Will you submit a PR?

  • Yes

Environment

Details
{
  "marimo": "0.22.0",
  "editable": false,
  "location": "/homelocal/ap286630/Documents/cabrnet/.venv/lib/python3.12/site-packages/marimo",
  "OS": "Linux",
  "OS Version": "6.8.0-107-generic",
  "Processor": "x86_64",
  "Python Version": "3.12.3",
  "Locale": "--",
  "Binaries": {
    "Browser": "--",
    "Node": "v18.19.1",
    "uv": "0.10.4"
  },
  "Dependencies": {
    "click": "8.3.1",
    "docutils": "0.22.4",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.10.2",
    "narwhals": "2.18.1",
    "packaging": "26.0",
    "psutil": "7.2.2",
    "pygments": "2.20.0",
    "pymdown-extensions": "10.21.2",
    "pyyaml": "6.0.3",
    "starlette": "1.0.0",
    "tomlkit": "0.12.0",
    "typing-extensions": "4.15.0",
    "uvicorn": "0.42.0",
    "websockets": "16.0"
  },
  "Optional Dependencies": {
    "altair": "6.0.0",
    "loro": "1.10.3",
    "mcp": "1.27.0",
    "pandas": "2.3.3",
    "polars": "1.39.3",
    "pyarrow": "23.0.1",
    "ruff": "0.15.9"
  },
  "Experimental Flags": {}
}

Code to reproduce

import marimo

__generated_with = "0.22.0"
app = marimo.App(width="medium")

with app.setup:
    import marimo as mo



@app.cell(hide_code=True)
def _():
    parameters = mo.md("""

    ### Parameters

    {a}
    {b}

    """).batch(
        a=mo.ui.slider(
            start=1,
            stop=50,
            step=1,
            value=10,
            show_value=True,
        ),
        b=mo.ui.number(
            value=0.2
        ),
    )
    return (parameters,)

if __name__ == "__main__":
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions