Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improve: do not trigger UI element warnings for state updates (#7102)

Akshay Agrawal0b3736266a73
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.py
index c2537fde86..8b376d4cdc 100644
--- a/marimo/_runtime/runtime.py
+++ b/marimo/_runtime/runtime.py
@@ -1470,6 +1470,16 @@ class Kernel:
cell_id = ctx.execution_context.cell_id
with self._state_lock:
self.state_updates[state] = cell_id
+ # TODO(akshayka): State should not be updated eagerly like this,
+ # the runner already handles state execution. This is a hack
+ # until we figure out how to clean this up.
+ names = ctx.state_registry.bound_names(state)
+ if len(names) == 1 and not (name := list(names)[0]).isidentifier():
+ LOGGER.warning(
+ f"Found 'name' for state object is not an identifier; got name {name}"
+ )
+ return
+
to_update = self.update_stateful_values(
ctx.state_registry.bound_names(state), state._value
)