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: default runtime configuration for dotenv (#7168)
Akshay Agrawaladb7000d674a
diff --git a/marimo/_config/config.py b/marimo/_config/config.pyindex d275dfdbfe..df7b063edd 100644--- a/marimo/_config/config.py+++ b/marimo/_config/config.py@@ -632,6 +632,8 @@ DEFAULT_CONFIG: MarimoConfig = {},"formatting": {"line_length": 79},"keymap": {"preset": "default", "overrides": {}},+ # dotenv's default value is set at runtime, depending on whether a+ # pyproject.toml is found."runtime": {"auto_instantiate": False,"auto_reload": "off",diff --git a/marimo/_config/manager.py b/marimo/_config/manager.pyindex 62790668c1..ae28f384a0 100644--- a/marimo/_config/manager.py+++ b/marimo/_config/manager.py@@ -193,7 +193,10 @@ class ProjectConfigManager(PartialMarimoConfigReader):return {}project_config = read_pyproject_marimo_config(self.pyproject_path)if project_config is None:- return {}+ # Some project configuration defaults (dotenv in particular)+ # are resolved at runtime, even in the absence of marimo+ # section in the pyproject.toml.+ project_config = cast(PartialMarimoConfig, {})project_config = self._resolve_pythonpath(project_config)project_config = self._resolve_dotenv(project_config)project_config = self._resolve_custom_css(project_config)diff --git a/tests/_config/test_manager.py b/tests/_config/test_manager.pyindex c672f0cb2e..87117928f2 100644--- a/tests/_config/test_manager.py+++ b/tests/_config/test_manager.py@@ -164,6 +164,21 @@ def test_with_multiple_overrides() -> None:assert manager.get_config()["package_management"]["manager"] == "pixi"+def test_project_config_default_dotenv(tmp_path: Path) -> None:+ # Even if the pyproject.toml does not have a marimo section,+ # at runtime the dotenv default should be injected.+ pyproject_path = tmp_path / "pyproject.toml"+ pyproject_content = ""+ pyproject_path.write_text(textwrap.dedent(pyproject_content))++ notebook_path = tmp_path / "notebook.py"+ notebook_content = "import marimo as mo"+ notebook_path.write_text(textwrap.dedent(notebook_content))+ manager = get_default_config_manager(current_path=str(notebook_path))+ config = manager.get_config(hide_secrets=False)+ assert config["runtime"]["dotenv"] == [str(tmp_path / ".env")]++def test_project_config_manager_with_script_metadata(tmp_path: Path) -> None:# Create a notebook file with script metadatanotebook_path = tmp_path / "notebook.py"