Skip to content

Fix spurious "truth value of UIElement" warning for anywidgets#8148

Merged
mscolnick merged 1 commit intomainfrom
push-qyxvmnrxlnlt
Feb 5, 2026
Merged

Fix spurious "truth value of UIElement" warning for anywidgets#8148
mscolnick merged 1 commit intomainfrom
push-qyxvmnrxlnlt

Conversation

@manzt
Copy link
Collaborator

@manzt manzt commented Feb 5, 2026

The from_anywidget cache lookup used if not (el := _cache.get(widget)) which evaluates the truthiness of the cached UIElement on subsequent lookups. Since UIElement.__bool__ writes a warning to stderr, displaying the same anywidget in multiple cells would trigger the misleading message "The truth value of a UIElement is always True. You probably want to call .value instead."

@vercel
Copy link

vercel bot commented Feb 5, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Feb 5, 2026 8:39pm

Request Review

@manzt manzt added the bug Something isn't working label Feb 5, 2026
mscolnick
mscolnick previously approved these changes Feb 5, 2026
Base automatically changed from ms/widget-model to main February 5, 2026 20:36
@mscolnick mscolnick dismissed their stale review February 5, 2026 20:36

The base branch was changed.

@github-actions github-actions bot added the bash-focus Area to focus on during release bug bash label Feb 5, 2026
The `from_anywidget` cache lookup used `if not (el :=
_cache.get(widget))` which evaluates the truthiness of the cached
UIElement on subsequent lookups. Since UIElement.__bool__ writes a
warning to stderr, displaying the same anywidget in multiple cells would
trigger the misleading message "The truth value of a UIElement is always
True. You probably want to call `.value` instead."

Switching to `is None` avoids the boolean coercion entirely.
@manzt manzt force-pushed the push-qyxvmnrxlnlt branch from 43beda8 to 8d3ad2c Compare February 5, 2026 20:38
@mscolnick mscolnick merged commit bd53833 into main Feb 5, 2026
20 of 23 checks passed
@mscolnick mscolnick deleted the push-qyxvmnrxlnlt branch February 5, 2026 20:39
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

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

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

Labels

bash-focus Area to focus on during release bug bash bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants