Skip to content

Document stale globals caveat on ctx.globals#8802

Merged
manzt merged 1 commit intomainfrom
push-tzsvnuzqosly
Mar 20, 2026
Merged

Document stale globals caveat on ctx.globals#8802
manzt merged 1 commit intomainfrom
push-tzsvnuzqosly

Conversation

@manzt
Copy link
Copy Markdown
Collaborator

@manzt manzt commented Mar 20, 2026

When code mode is used from the scratchpad, run_cell updates the kernel's globals but not the scratchpad's shallow copy. This means bare variable names read stale values. The docstring now directs callers to use ctx.globals["x"] instead.

When code mode is used from the scratchpad, `run_cell` updates the
kernel's globals but not the scratchpad's shallow copy. This means bare
variable names read stale values. The docstring now directs callers to
use `ctx.globals["x"]` instead.
Copilot AI review requested due to automatic review settings March 20, 2026 21:53
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 20, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 20, 2026 9:54pm

Request Review

@manzt manzt added the enhancement New feature or request label Mar 20, 2026
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

Updates the ctx.globals docstring to document a scratchpad-specific caveat in code mode: run_cell updates the kernel’s globals, but bare variable names in the scratchpad may still reflect a stale shallow copy, so callers should read values via ctx.globals["x"].

Changes:

  • Expand globals property docstring to explain stale scratchpad globals behavior after run_cell
  • Add guidance to prefer ctx.globals["x"] over bare variable names when reading updated values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@manzt manzt merged commit e191472 into main Mar 20, 2026
48 of 49 checks passed
@manzt manzt deleted the push-tzsvnuzqosly branch March 20, 2026 22:06
@github-actions
Copy link
Copy Markdown

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

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants