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
tests: remove "dev" from minimal deps, and fix flakey test_resume_session_with_watch (#8232)
Myles Scolnickb26d79b653c0
diff --git a/pyproject.toml b/pyproject.tomlindex 445d6b3fcb..f9aed68c04 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -117,7 +117,7 @@ mcp = [[dependency-groups]dev = [- "hatch>=1.15.1",+ "hatch>=1.16.3","black~=23.12.1",# For tracing debugging"opentelemetry-api~=1.28.0",@@ -274,7 +274,7 @@ check = "mypy marimo --exclude=marimo/_tutorials/"tutorials = "mypy marimo/_tutorials"[tool.hatch.envs.test]-dependency-groups = ["dev", "test"]+dependency-groups = ["test"][[tool.hatch.envs.test.matrix]]python = ["3.10", "3.11", "3.12", "3.13", "3.14"]@@ -597,7 +597,7 @@ platforms = ["osx-arm64", "linux-64", "linux-aarch64"][tool.pixi.dependencies]nodejs = "22.*"pnpm = "10.*"-hatch = ">=1.14.1,<2"+hatch = ">=1.16.3,<2"make = ">=4.4.1,<5"pre_commit = ">=4.2.0,<5"uv = ">=0.6.12,<0.7"diff --git a/tests/_ai/test_ai_types.py b/tests/_ai/test_ai_types.pyindex 3e090dad0b..2f262bd5b2 100644--- a/tests/_ai/test_ai_types.py+++ b/tests/_ai/test_ai_types.py@@ -100,8 +100,8 @@ class TestChatMessageCreate:)@pytest.mark.skipif(- not DependencyManager.pydantic.has(),- reason="pydantic is not installed",+ not DependencyManager.pydantic_ai.has(),+ reason="pydantic_ai is not installed",)def test_dict_parts_with_dataclass_validator(self):"""Test converting dict parts using a dataclass validator."""@@ -123,8 +123,8 @@ class TestChatMessageCreate:)@pytest.mark.skipif(- not DependencyManager.pydantic.has(),- reason="pydantic is not installed",+ not DependencyManager.pydantic_ai.has(),+ reason="pydantic_ai is not installed",)def test_mixed_parts_with_validator(self):"""Test with a mix of already-typed and dict parts."""diff --git a/tests/_convert/markdown/test_markdown_conversion.py b/tests/_convert/markdown/test_markdown_conversion.pyindex 1491dd0b5c..c22e22b5b8 100644--- a/tests/_convert/markdown/test_markdown_conversion.py+++ b/tests/_convert/markdown/test_markdown_conversion.py@@ -172,6 +172,7 @@ def test_markdown_just_frontmatter() -> None:assert app.cell_manager.cell_data_at(ids[0]).code == ""[email protected]("duckdb")def test_markdown_with_sql() -> None:script = dedent(remove_empty_lines(diff --git a/tests/_data/test_get_datasets.py b/tests/_data/test_get_datasets.pyindex b3ca5023a8..8e3ae33cef 100644--- a/tests/_data/test_get_datasets.py+++ b/tests/_data/test_get_datasets.py@@ -540,6 +540,7 @@ def test_get_datasets_from_variables(df: Any) -> None:][email protected]("duckdb")def test_get_table_columns() -> None:import duckdb@@ -550,6 +551,7 @@ def test_get_table_columns() -> None:assert columns == all_types_tables[0].columns[email protected]("duckdb")def test_get_databases_agg_query() -> None:import duckdbdiff --git a/tests/_pyodide/test_pyodide_session.py b/tests/_pyodide/test_pyodide_session.pyindex 7a43eaa452..4d0440d255 100644--- a/tests/_pyodide/test_pyodide_session.py+++ b/tests/_pyodide/test_pyodide_session.py@@ -12,6 +12,7 @@ import pytestfrom marimo._ast.app_config import _AppConfigfrom marimo._config.config import DEFAULT_CONFIG+from marimo._dependencies.dependencies import DependencyManagerfrom marimo._messaging.types import KernelMessagefrom marimo._pyodide.pyodide_session import (AsyncQueueManager,@@ -573,6 +574,10 @@ def test_pyodide_bridge_read_code(assert "marimo.App()" in response["contents"]+ not (DependencyManager.ruff.has() or DependencyManager.black.has()),+ reason="ruff or black not installed",+)async def test_pyodide_bridge_format(pyodide_bridge: PyodideBridge) -> None:"""Test formatting code through the bridge."""request_json = json.dumps(diff --git a/tests/_runtime/test_dataflow_cases.py b/tests/_runtime/test_dataflow_cases.pyindex dbe6bddf7d..077eea4ed2 100644--- a/tests/_runtime/test_dataflow_cases.py+++ b/tests/_runtime/test_dataflow_cases.py@@ -154,6 +154,7 @@ PYTHON_CASES = [SQL_CASES = [GraphTestCase(name="python -> sql",+ enabled=HAS_DUCKDB,code={"0": "df = pd.read_csv('data.csv')","1": "result = mo.sql(f'FROM df WHERE name = {name}')",@@ -165,6 +166,7 @@ SQL_CASES = [),GraphTestCase(name="sql -> python via output",+ enabled=HAS_DUCKDB,code={"0": "result = mo.sql(f'FROM my_table WHERE name = {name}')","1": "df = result.head()",@@ -176,6 +178,7 @@ SQL_CASES = [),GraphTestCase(name="sql -/> python when creating a table",+ enabled=HAS_DUCKDB,code={"0": "_ = mo.sql(f'CREATE TABLE my_table (name STRING)')","1": "my_table = df.head()",@@ -187,6 +190,7 @@ SQL_CASES = [),GraphTestCase(name="sql redefinition",+ enabled=HAS_DUCKDB,code={"0": "df = pd.read_csv('data.csv')","1": "df = mo.sql(f'FROM df')",diff --git a/tests/_server/ai/test_providers.py b/tests/_server/ai/test_providers.pyindex b7f1da584b..cbf811dbec 100644--- a/tests/_server/ai/test_providers.py+++ b/tests/_server/ai/test_providers.py@@ -90,6 +90,9 @@ def test_get_completion_provider() -> None:"""Test that the correct provider is returned for a given model."""+ if not DependencyManager.pydantic_ai.has():+ pytest.skip("requires pydantic_ai")+if dependency and not dependency.has():pytest.skip(f"{dependency.pkg} is not installed")@@ -107,6 +110,7 @@ def test_get_completion_provider(assert isinstance(provider, provider_type)[email protected]("pydantic_ai")async def test_azure_openai_provider() -> None:"""Test that Azure OpenAI provider uses correct parameters."""config = AnyProviderConfig(@@ -272,6 +276,7 @@ def test_anthropic_process_part_text_file() -> None:),],)[email protected]("pydantic_ai")def test_is_reasoning_model(model_name: str, base_url: str | None, expected: bool) -> None:diff --git a/tests/_server/api/endpoints/test_ai.py b/tests/_server/api/endpoints/test_ai.pyindex b6aff2ce51..993afe3e91 100644--- a/tests/_server/api/endpoints/test_ai.py+++ b/tests/_server/api/endpoints/test_ai.py@@ -7,7 +7,6 @@ from unittest.mock import AsyncMock, MagicMock, patchimport pytest-from marimo._dependencies.dependencies import DependencyManagerfrom marimo._server.ai.prompts import (FIM_MIDDLE_TAG,FIM_PREFIX_TAG,@@ -30,10 +29,6 @@ HEADERS = {**token_header("fake-token"),}-HAS_OPEN_AI_DEPS = DependencyManager.openai.has()-HAS_ANTHROPIC_DEPS = DependencyManager.anthropic.has()-HAS_GOOGLE_AI_DEPS = DependencyManager.google_ai.has()-# Anthropic@dataclass@@ -83,9 +78,7 @@ def _create_messages(prompt: str) -> list[dict[str, Any]]:]- not HAS_OPEN_AI_DEPS, reason="optional dependencies not installed"-)[email protected]("openai", "pydantic_ai")class TestOpenAiEndpoints:@staticmethod@with_session(SESSION_ID)@@ -339,9 +332,7 @@ class TestOpenAiEndpoints:assert "sql" in call_kwargs["system_prompt"].lower()- not HAS_ANTHROPIC_DEPS, reason="optional dependencies not installed"-)[email protected]("anthropic", "pydantic_ai")class TestAnthropicAiEndpoints:@staticmethod@with_session(SESSION_ID)@@ -443,9 +434,7 @@ class TestAnthropicAiEndpoints:)- not HAS_GOOGLE_AI_DEPS, reason="optional dependencies not installed"-)[email protected]("google_ai", "pydantic_ai")class TestGoogleAiEndpoints:@staticmethod@with_session(SESSION_ID)@@ -667,6 +656,7 @@ def _google_ai_config():}[email protected]("openai", "pydantic_ai")@with_session(SESSION_ID)@patch("marimo._server.ai.providers.OpenAIProvider.stream_completion")def test_chat_without_code(@@ -707,6 +697,7 @@ def test_chat_without_code(mock_stream_completion.assert_called_once()[email protected]("openai", "pydantic_ai")@with_session(SESSION_ID)@patch("marimo._server.ai.providers.OpenAIProvider.stream_completion")def test_chat_with_code(diff --git a/tests/_server/api/endpoints/test_editing.py b/tests/_server/api/endpoints/test_editing.pyindex 171215c411..9a18e36d8e 100644--- a/tests/_server/api/endpoints/test_editing.py+++ b/tests/_server/api/endpoints/test_editing.py@@ -3,8 +3,13 @@ from __future__ import annotationsfrom typing import TYPE_CHECKING+import pytest++from marimo._dependencies.dependencies import DependencyManagerfrom tests._server.mocks import token_header, with_session+HAS_FORMATTER = DependencyManager.ruff.has() or DependencyManager.black.has()+if TYPE_CHECKING:from starlette.testclient import TestClient@@ -45,6 +50,7 @@ def test_delete_cell(client: TestClient) -> None:assert "success" in response.json()[email protected](not HAS_FORMATTER, reason="ruff or black not installed")@with_session(SESSION_ID)def test_format_cell(client: TestClient) -> None:response = client.post(diff --git a/tests/_server/api/endpoints/test_resume_session.py b/tests/_server/api/endpoints/test_resume_session.pyindex b083ff4aef..c9714a4304 100644--- a/tests/_server/api/endpoints/test_resume_session.py+++ b/tests/_server/api/endpoints/test_resume_session.py@@ -5,8 +5,6 @@ import timefrom contextlib import contextmanagerfrom typing import TYPE_CHECKING, Any, Optional-import pytest-from marimo._config.manager import UserConfigManagerfrom marimo._messaging.msgspec_encoder import asdictfrom marimo._messaging.notification import (@@ -297,7 +295,6 @@ def test_restart_session(client: TestClient) -> None:# Shutdown the kernel[email protected](reruns=5)def test_resume_session_with_watch(client: TestClient) -> None:session_manager = get_session_manager(client)session_manager.watch = True@@ -335,8 +332,12 @@ def test_resume_session_with_watch(client: TestClient) -> None:},}+ # Stop the file watcher before resuming to prevent duplicate filesystem+ # events from racing with the session replay messages.+ session_manager._watcher_manager.stop_all()+ session_manager.watch = False+# Resume session with new ID (simulates refresh)- # watcher_on_save is 'autorun', so we should expect the cell to be runwith client.websocket_connect(_create_ws_url("456")) as websocket:# First message is the kernel reconnecteddata = websocket.receive_json()@@ -347,14 +348,14 @@ def test_resume_session_with_watch(client: TestClient) -> None:assert parse_raw(data["data"], KernelReadyNotification)messages: list[dict[str, Any]] = []- # Wait for update-cell-codes message+ # Wait for update-cell-ids messagewhile True:data = websocket.receive_json()messages.append(data)if data["op"] == "update-cell-ids":break- # 3 messages:+ # 2 messages:# 1. banner# 2. update-cell-idsassert len(messages) == 2@@ -369,9 +370,6 @@ def test_resume_session_with_watch(client: TestClient) -> None:session_view = session.session_viewassert session_view.last_executed_code == {"MJUe": "x=10; x"}- session_manager.watch = False- session_manager._watcher_manager.stop_all()-@contextmanagerdef without_autorun_on_save(config: UserConfigManager):diff --git a/tests/_sql/test_sql.py b/tests/_sql/test_sql.pyindex 4329ffb444..562e24b3fe 100644--- a/tests/_sql/test_sql.py+++ b/tests/_sql/test_sql.py@@ -252,7 +252,7 @@ def test_query_includes_limit() -> None:@patch("marimo._sql.sql.replace")[email protected](not HAS_POLARS and HAS_DUCKDB, reason="polars is required")[email protected]("polars", "duckdb")def test_applies_limit(mock_replace: MagicMock) -> None:import duckdb@@ -314,7 +314,7 @@ def test_sql_raises_error_without_duckdb():@patch("marimo._sql.sql.replace")[email protected](not HAS_POLARS and HAS_DUCKDB, reason="polars is required")[email protected]("polars", "duckdb")def test_sql_output_flag(mock_replace: MagicMock) -> None:import duckdbimport polars as pldiff --git a/tests/_sql/test_sql_error_handling.py b/tests/_sql/test_sql_error_handling.pyindex db44ccfadc..127e8decd5 100644--- a/tests/_sql/test_sql_error_handling.py+++ b/tests/_sql/test_sql_error_handling.py@@ -209,6 +209,7 @@ class TestErrorUtilityFunctions:# Hint field should exist (may be None for this error)assert hasattr(error, "hint")+ @pytest.mark.requires("duckdb")def test_create_sql_error_long_statement(self):"""Test SQL statement truncation in error creation."""import duckdb@@ -321,6 +322,7 @@ class TestIntegrationAndEdgeCases:with pytest.raises(MarimoSQLException):sql("SELECT * FROM table2_nonexistent")+ @pytest.mark.requires("duckdb")def test_error_with_special_characters(self):"""Test error handling with SQL containing special characters."""with pytest.raises(MarimoSQLException):diff --git a/tests/_sql/test_sql_parse.py b/tests/_sql/test_sql_parse.pyindex 0108e4916d..cd5f554447 100644--- a/tests/_sql/test_sql_parse.py+++ b/tests/_sql/test_sql_parse.py@@ -61,6 +61,9 @@ class TestUnsupportedDialects:assert result is Noneassert error == "Unsupported dialect: postgresql"+ @pytest.mark.requires("duckdb")+ def test_duckdb_dialect_with_whitespace(self):+ """Test duckdb dialect with leading/trailing whitespace."""result, error = parse_sql("SELECT 1", " duckdb ")assert result is not Noneassert error is None