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
pretty print module value in variables table (#154)
Akshay Agrawal632ca754e581
diff --git a/marimo/_messaging/ops.py b/marimo/_messaging/ops.pyindex fa6d2e4e0a..9a4153b50c 100644--- a/marimo/_messaging/ops.py+++ b/marimo/_messaging/ops.py@@ -9,6 +9,7 @@ from __future__ import annotationsimport sysimport timefrom dataclasses import asdict, dataclass, field+from types import ModuleTypefrom typing import (Any,ClassVar,@@ -235,10 +236,14 @@ class VariableValue:def __init__(self, name: str, value: object):self.name = name++ # Defensively try-catch attribute accesses, which could raise+ # exceptionstry:self.datatype = type(value).__name__ if value is not None else Noneexcept Exception:self.datatype = None+try:self.value = self._format_value(value)except Exception:@@ -248,12 +253,14 @@ class VariableValue:return str(value)[:50]def _format_value(self, value: object) -> str:+ resolved = valueif isinstance(value, UIElement):- return self._stringify(value.value)+ resolved = value.valueelif isinstance(value, Html):- return self._stringify(value.text)- else:- return self._stringify(value)+ resolved = value.text+ elif isinstance(value, ModuleType):+ resolved = value.__name__+ return self._stringify(resolved)@dataclass