Skip to content

fix(table): accept ChartDataType in mo.ui.table to resolve pyright error when passing chart.value#9674

Merged
Light2Dark merged 2 commits into
marimo-team:mainfrom
VishakBaddur:fix/table-chart-value-type-annotation
May 30, 2026
Merged

fix(table): accept ChartDataType in mo.ui.table to resolve pyright error when passing chart.value#9674
Light2Dark merged 2 commits into
marimo-team:mainfrom
VishakBaddur:fix/table-chart-value-type-annotation

Conversation

@VishakBaddur
Copy link
Copy Markdown
Contributor

@VishakBaddur VishakBaddur commented May 23, 2026

Problem

mo.ui.altair_chart.value is typed as ChartDataType, which includes IntoLazyFrame, list[dict[str, Any]], and dict[str, list[Any]]. But mo.ui.table.__init__'s data parameter only declared IntoDataFrame, not the other three members. This caused pyright to flag the common pattern mo.ui.table(chart.value) as a type error, even though it works correctly at runtime. This is the inline type error visible in VS Code reported in issue #8292.

Fix

Added the missing types (IntoLazyFrame, list[dict[str, Any]], dict[str, list[Any]]) to:

  • mo.ui.table.__init__'s data parameter type annotation
  • TableData in dataframe.py

The on_change callback type annotation was kept consistent with _convert_value's actual return type and not widened.

No runtime behavior changes - this is a type annotation-only fix.

Verification

  • Confirmed pyright errors on mo.ui.table(chart.value) before the fix, passes after
  • All existing table tests pass

Note

The infinite re-run described in the issue could not be reproduced on current main and appears environment-specific (VS Code + Ruff LSP). This PR addresses the reproducible type error only.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 25, 2026 10:20pm

Request Review

@Light2Dark Light2Dark added the bug Something isn't working label May 25, 2026
@Light2Dark
Copy link
Copy Markdown
Collaborator

There are some type errors

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates type annotations so mo.ui.table(...) can accept mo.ui.altair_chart.value (typed as ChartDataType) without triggering pyright errors, aligning the table API with the data shapes produced by reactive Altair charts.

Changes:

  • Expanded mo.ui.table.__init__’s data parameter type to include row/column-oriented chart payloads and IntoLazyFrame.
  • Expanded mo.ui.table.__init__’s on_change callback annotation accordingly.
  • Updated the shared TableData type alias in dataframe.py to include IntoLazyFrame.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
marimo/_plugins/ui/_impl/utils/dataframe.py Extends TableData to include IntoLazyFrame for shared typing across table utilities.
marimo/_plugins/ui/_impl/table.py Widens the table constructor and callback type annotations to accept chart-derived data shapes.

Comment on lines 71 to 72
ListOrTuple[dict[str, JSONType]],
dict[str, ListOrTuple[JSONType]],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. list[dict[str, Any]] and dict[str, list[Any]] are now included in TableData

Comment on lines +546 to +547
| IntoDataFrame
| IntoLazyFrame,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Users passing a lazy frame directly should use table.lazy() for proper lazy behavior, this is existing guidance and unchanged by this PR. The type annotation accurately reflects what the runtime accepts.

Comment thread marimo/_plugins/ui/_impl/table.py Outdated
@VishakBaddur VishakBaddur force-pushed the fix/table-chart-value-type-annotation branch from 6e409b4 to 5e80db5 Compare May 25, 2026 21:44
@Light2Dark Light2Dark merged commit 58b7b5f into marimo-team:main May 30, 2026
39 checks passed
@Light2Dark
Copy link
Copy Markdown
Collaborator

thanks!

@github-actions
Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.9-dev25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants