fix(table): accept ChartDataType in mo.ui.table to resolve pyright error when passing chart.value#9674
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
There are some type errors |
There was a problem hiding this comment.
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__’sdataparameter type to include row/column-oriented chart payloads andIntoLazyFrame. - Expanded
mo.ui.table.__init__’son_changecallback annotation accordingly. - Updated the shared
TableDatatype alias indataframe.pyto includeIntoLazyFrame.
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. |
| ListOrTuple[dict[str, JSONType]], | ||
| dict[str, ListOrTuple[JSONType]], |
There was a problem hiding this comment.
Done. list[dict[str, Any]] and dict[str, list[Any]] are now included in TableData
| | IntoDataFrame | ||
| | IntoLazyFrame, |
There was a problem hiding this comment.
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.
6e409b4 to
5e80db5
Compare
…ror when passing chart.value
5e80db5 to
f724e3f
Compare
|
thanks! |
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.9-dev25 |
Problem
mo.ui.altair_chart.valueis typed asChartDataType, which includesIntoLazyFrame,list[dict[str, Any]], anddict[str, list[Any]]. Butmo.ui.table.__init__'sdataparameter only declaredIntoDataFrame, not the other three members. This caused pyright to flag the common patternmo.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__'sdataparameter type annotationTableDataindataframe.pyThe
on_changecallback 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
mo.ui.table(chart.value)before the fix, passes afterNote
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.