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
fix: don't import tomlkit top-level (#2103)
Akshay Agrawalc8cdd52ca200
diff --git a/marimo/_cli/config/commands.py b/marimo/_cli/config/commands.pyindex a7d52f22b6..4e9bbe2611 100644--- a/marimo/_cli/config/commands.py+++ b/marimo/_cli/config/commands.py@@ -2,7 +2,6 @@from __future__ import annotationsimport click-import tomlkitfrom marimo._cli.config.utils import highlight_toml_headersfrom marimo._cli.print import green@@ -22,6 +21,8 @@ def show() -> None:marimo config show"""+ import tomlkit+config_manager = UserConfigManager()click.echo(f"User config from {green(config_manager.get_config_path())}\n")toml_string = tomlkit.dumps(config_manager.get_config())diff --git a/marimo/_utils/config/config.py b/marimo/_utils/config/config.pyindex dd98c3581e..4e899386e9 100644--- a/marimo/_utils/config/config.py+++ b/marimo/_utils/config/config.py@@ -4,8 +4,6 @@ from dataclasses import asdictfrom tempfile import TemporaryDirectoryfrom typing import Any, Optional, Type, TypeVar-import tomlkit-from marimo._utils.parse_dataclass import parse_rawROOT_DIR = ".marimo"@@ -30,6 +28,8 @@ class ConfigReader:return ConfigReader(filepath)def read_toml(self, cls: Type[T], *, fallback: T) -> T:+ import tomlkit+try:with open(self.filepath, "r") as file:data = tomlkit.parse(file.read())@@ -38,6 +38,8 @@ class ConfigReader:return fallbackdef write_toml(self, data: Any) -> None:+ import tomlkit+_maybe_create_directory(self.filepath)with open(self.filepath, "w") as file:tomlkit.dump(asdict(data), file)diff --git a/pyproject.toml b/pyproject.tomlindex ac888c1613..3684213e1b 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -260,7 +260,7 @@ docstring-code-format = trueban-relative-imports = "all"# Ban certain modules from being imported at module level, instead requiring# that they're imported lazily (e.g., within a function definition).-banned-module-level-imports = ["numpy", "pandas"]+banned-module-level-imports = ["numpy", "pandas", "tomlkit"][tool.ruff.lint.flake8-pytest-style]mark-parentheses = falsediff --git a/tests/_cli/test_cli.py b/tests/_cli/test_cli.pyindex c7047e6850..92d3233bf9 100644--- a/tests/_cli/test_cli.py+++ b/tests/_cli/test_cli.py@@ -20,7 +20,6 @@ import urllib.requestfrom typing import Any, Callable, Iterator, Optionalimport pytest-import tomlkitfrom marimo import __version__from marimo._ast import codegen@@ -138,6 +137,8 @@ def _get_port() -> int:def _read_toml(filepath: str) -> Optional[dict]:+ import tomlkit+if not os.path.exists(filepath):return Nonewith open(filepath, "r") as file: