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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improve: contextual docs hint for local variables on NameError (#7522)
Akshay Agrawal9c67d8ba0ab3
diff --git a/frontend/src/components/editor/output/MarimoErrorOutput.tsx b/frontend/src/components/editor/output/MarimoErrorOutput.tsxindex 22d5ac4194..b44d7c4f25 100644--- a/frontend/src/components/editor/output/MarimoErrorOutput.tsx+++ b/frontend/src/components/editor/output/MarimoErrorOutput.tsx@@ -295,9 +295,9 @@ export const MarimoErrorOutput = ({<p className="py-2">Try merging this cell with the mentioned cells or wrapping it in a- function. Alternatively, rename variables to make them private to- this cell by prefixing them with an underscore (e.g.{" "}- <Kbd className="inline">_{firstName}</Kbd>).+ function. Alternatively, prefix variables with an underscore+ (e.g., <Kbd className="inline">_{firstName}</Kbd>). to make them+ private to this cell.</p><p className="py-2">@@ -407,6 +407,34 @@ export const MarimoErrorOutput = ({);}+ if (+ error.exception_type === "NameError" &&+ error.msg.startsWith("name '_")+ ) {+ return (+ <li className="my-2" key={`exception-${idx}`}>+ <div>+ <p className="text-muted-foreground">{error.msg}</p>+ <p className="text-muted-foreground mt-2">+ Variables prefixed with an underscore are local to a cell{" "}+ (+ <ExternalLink href="https://links.marimo.app/local-variables">+ docs{" "}+ <SquareArrowOutUpRightIcon+ size="0.75rem"+ className="inline"+ />+ </ExternalLink>+ ).+ </p>+ <div className="text-muted-foreground mt-2">+ See the console area for a traceback.+ </div>+ </div>+ </li>+ );+ }+return (<li className="my-2" key={`exception-${idx}`}>{error.raising_cell == null ? (