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: Windows CI test failures (#8656)
Myles Scolnick7d568bf208a1
diff --git a/marimo/_ast/sql_visitor.py b/marimo/_ast/sql_visitor.pyindex ec92a89c3a..8dc9496e3b 100644--- a/marimo/_ast/sql_visitor.py+++ b/marimo/_ast/sql_visitor.py@@ -509,7 +509,11 @@ def find_sql_refs(sql_statement: str) -> set[SQLRef]:def get_ref_from_table(table: exp.Table) -> Optional[SQLRef]:# The variables might be empty strings, if they are, we set them to None- table_name = table.name or None+ try:+ table_name = table.name or None+ except AttributeError:+ # sqlglot may return Table nodes with this=None (e.g. DROP SCHEMA)+ return Noneschema_name = table.db or Nonecatalog_name = table.catalog or Nonediff --git a/marimo/_server/api/lifespans.py b/marimo/_server/api/lifespans.pyindex da80d55620..c64a268d59 100644--- a/marimo/_server/api/lifespans.py+++ b/marimo/_server/api/lifespans.py@@ -215,13 +215,13 @@ async def etc(app: Starlette) -> AsyncIterator[None]:yield-def _pretty_print_host(host: str, port: int) -> str:+def _pretty_host(host: str, port: int) -> str:"""Replace loopback addresses with 'localhost' for display.Uses ipaddress for a reliable cross-platform loopback check (covers127.0.0.1, ::1, and the full 127.0.0.0/8 range). Falls back tosocket.getnameinfo only for non-IP hosts. getnameinfo is skipped for- raw IP addresses because it can hang on Windows for link-local IPv6.+ raw IP addresses because it can hang on Windows/CI for link-local IPv6."""try:if ipaddress.ip_address(host).is_loopback:@@ -247,12 +247,12 @@ def _startup_url(state: AppStateBase) -> str:# Strip IPv6 zone ID (e.g. fe80::1%eth0 -> fe80::1); zone IDs are# interface-specific and not valid in URLs.- # Must happen before getnameinfo — zone IDs can cause it to hang- # on Windows.+ # Must happen before _pretty_host — zone IDs can cause getnameinfo+ # to hang on Windows/CI.host = host.split("%")[0]# pretty printing: show "localhost" for loopback addresses- host = _pretty_print_host(host, port)+ host = _pretty_host(host, port)url_host_bare = host# IPv6 addresses must be wrapped in brackets in URLs (RFC 3986)@@ -277,7 +277,7 @@ def _mcp_startup_url(state: AppStateBase) -> str:# Strip zone ID, then pretty-print loopback (same logic as _startup_url)host = host.split("%")[0]- host = _pretty_print_host(host, port)+ host = _pretty_host(host, port)url_host_bare = hosturl_host = f"[{url_host_bare}]" if ":" in url_host_bare else url_host_barediff --git a/marimo/_server/export/exporter.py b/marimo/_server/export/exporter.pyindex cbf3804763..ad898c550d 100644--- a/marimo/_server/export/exporter.py+++ b/marimo/_server/export/exporter.py@@ -373,9 +373,9 @@ class Exporter:PDFExporter,)- exporter = PDFExporter()+ exporter = PDFExporter() # type: ignore[no-untyped-call]exporter.exclude_input = not include_inputs- pdf_data, _resources = exporter.from_notebook_node(notebook)+ pdf_data, _resources = exporter.from_notebook_node(notebook) # type: ignore[no-untyped-call]if isinstance(pdf_data, bytes):return pdf_dataLOGGER.error("PDF data is not bytes: %s", pdf_data)@@ -388,10 +388,10 @@ class Exporter:from nbconvert import WebPDFExporter # type: ignore[import-not-found]- web_exporter = WebPDFExporter()+ web_exporter = WebPDFExporter() # type: ignore[no-untyped-call]web_exporter.exclude_input = not include_inputsweb_exporter.allow_chromium_download = True- pdf_data, _resources = web_exporter.from_notebook_node(notebook)+ pdf_data, _resources = web_exporter.from_notebook_node(notebook) # type: ignore[no-untyped-call]if not isinstance(pdf_data, bytes):LOGGER.error("PDF data is not bytes: %s", pdf_data)@@ -490,9 +490,9 @@ class Exporter:)# Convert to reveal.js HTML- slides_exporter = SlidesExporter()+ slides_exporter = SlidesExporter() # type: ignore[no-untyped-call]slides_exporter.exclude_input = not include_inputs- html_data, _resources = slides_exporter.from_notebook_node(notebook)+ html_data, _resources = slides_exporter.from_notebook_node(notebook) # type: ignore[no-untyped-call]# Write HTML to a temp file for Playwright to loadwith tempfile.NamedTemporaryFile(diff --git a/pyproject.toml b/pyproject.tomlindex dc4f6b96bb..99ba39c393 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -84,7 +84,7 @@ marimo_converter = "marimo._utils.docs:MarimoConverter"sql = ["duckdb>=1.0.0", # SQL cells"polars[pyarrow]>=1.9.0", # SQL output back in Python- "sqlglot[c]>=26.2.0" # SQL cells parsing;+ "sqlglot[c]>=26.8.0" # SQL cells parsing;]# For per-notebook sandboxed kernels@@ -123,7 +123,7 @@ dev = ["opentelemetry-sdk~=1.28.0",# For SQL"duckdb>=1.0.0",- "sqlglot[c]>=26.2.0",+ "sqlglot[c]>=26.8.0",# Stubs for optional dataframe backends"pyarrow-stubs",# For linting@@ -169,7 +169,7 @@ test-optional = ["altair>=5.4.0","plotly>=5.14.0","polars>=1.32.2",- "sqlglot[c]>=26.2.0",+ "sqlglot[c]>=26.8.0","sqlalchemy>=2.0.40","obstore>=0.8.2","fsspec>=2026.2.0",@@ -222,7 +222,7 @@ typecheck = ["duckdb>=1.0.0","narwhals>=2.0.0","matplotlib>=3.8.0",- "sqlglot[c]>=26.2.0",+ "sqlglot[c]>=26.8.0","sqlalchemy>=2.0.40","obstore>=0.8.2","fsspec>=2026.2.0",@@ -462,8 +462,8 @@ addopts = "-ra -q -v --ignore tests/_cli/fixtures --ignore tests/_ast/codegen_datestpaths = ["tests"]asyncio_mode = "auto"asyncio_default_fixture_loop_scope = "function"-timeout = 30 # seconds, per test-faulthandler_timeout = 30 # seconds, during collection+timeout = 120 # seconds, per test (Windows CI needs extra headroom)+faulthandler_timeout = 120 # seconds, during collectionmarkers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')","integration: marks tests as integration tests",diff --git a/tests/_cli/test_cli_export.py b/tests/_cli/test_cli_export.pyindex b798f457e7..a06e269b7f 100644--- a/tests/_cli/test_cli_export.py+++ b/tests/_cli/test_cli_export.py@@ -60,6 +60,36 @@ def _is_win32() -> bool:return sys.platform == "win32"+def _playwright_browsers_installed() -> bool:+ """Check if Playwright Chromium browser binary is actually installed."""+ try:+ import os++ # Playwright stores browsers in PLAYWRIGHT_BROWSERS_PATH or+ # the default cache: ~/.cache/ms-playwright (Linux),+ # ~/Library/Caches/ms-playwright (macOS)+ browsers_path = os.environ.get("PLAYWRIGHT_BROWSERS_PATH")+ if not browsers_path:+ if sys.platform == "darwin":+ browsers_path = str(+ Path.home() / "Library" / "Caches" / "ms-playwright"+ )+ elif sys.platform == "win32":+ local = os.environ.get("LOCALAPPDATA", "")+ browsers_path = (+ str(Path(local) / "ms-playwright") if local else ""+ )+ else:+ browsers_path = str(Path.home() / ".cache" / "ms-playwright")+ p = Path(browsers_path)+ if not p.exists():+ return False+ # Check if any chromium directory exists+ return any(d.name.startswith("chromium") for d in p.iterdir())+ except Exception:+ return False++_runner = CliRunner()@@ -1149,6 +1179,11 @@ class TestExportPDF:not DependencyManager.playwright.has(),reason="This test requires playwright.",)+ DependencyManager.playwright.has()+ and not _playwright_browsers_installed(),+ reason="Playwright browsers are not installed.",+)class TestExportThumbnail:def test_export_thumbnail(self, temp_marimo_file: str) -> None:p = _run_export("thumbnail", temp_marimo_file)diff --git a/tests/_cli/test_sandbox.py b/tests/_cli/test_sandbox.pyindex 0f1a84f9e7..0d781eee75 100644--- a/tests/_cli/test_sandbox.py+++ b/tests/_cli/test_sandbox.py@@ -133,7 +133,7 @@ def test_construct_uv_cmd_marimo_edit_empty_file() -> None:additional_deps=[],)assert "--refresh" in uv_cmd- assert uv_cmd[0].endswith("uv")+ assert os.path.basename(uv_cmd[0]).startswith("uv")assert uv_cmd[1] == "run"@@ -148,7 +148,7 @@ def test_construct_uv_cmd_marimo_edit_file_no_sandbox(additional_deps=[],)assert "--refresh" in uv_cmd- assert uv_cmd[0].endswith("uv")+ assert os.path.basename(uv_cmd[0]).startswith("uv")assert uv_cmd[1] == "run"@@ -164,7 +164,7 @@ def test_construct_uv_cmd_marimo_edit_sandboxed_file(additional_deps=[],)assert "--refresh" not in uv_cmd- assert uv_cmd[0].endswith("uv")+ assert os.path.basename(uv_cmd[0]).startswith("uv")assert uv_cmd[1] == "run"diff --git a/tests/_config/test_config_packages.py b/tests/_config/test_config_packages.pyindex acb48259cf..b189c72117 100644--- a/tests/_config/test_config_packages.py+++ b/tests/_config/test_config_packages.py@@ -122,8 +122,16 @@ def test_infer_package_manager(else:(mock_cwd / filename).write_text(content)+ # Ensure CI env vars (e.g. UV set by uv-based runners) don't leak+ # into the test. Start from a clean slate for the keys that+ # infer_package_manager inspects, then layer on env_vars.+ sanitized = {+ k: v for k, v in os.environ.items() if k not in ("UV", "VIRTUAL_ENV")+ }+ sanitized.update(env_vars)+# Mock environment variables- with patch.dict(os.environ, env_vars):+ with patch.dict(os.environ, sanitized, clear=True):# Mock sys attributesif sys_attrs:with patch.multiple(sys, **sys_attrs):diff --git a/tests/_plugins/ui/_impl/test_anywidget.py b/tests/_plugins/ui/_impl/test_anywidget.pyindex c4e49839a2..213884f0e8 100644--- a/tests/_plugins/ui/_impl/test_anywidget.py+++ b/tests/_plugins/ui/_impl/test_anywidget.py@@ -25,7 +25,9 @@ from marimo._types.ids import WidgetModelIdfrom tests.conftest import ExecReqProviderHAS_DEPS = (- DependencyManager.anywidget.has() and DependencyManager.traitlets.has()+ DependencyManager.anywidget.has()+ and DependencyManager.traitlets.has()+ and hasattr(__import__("anywidget"), "AnyWidget"))HAS_PLOTLY = DependencyManager.plotly.has()diff --git a/tests/_utils/test_uv_tree.py b/tests/_utils/test_uv_tree.pyindex 24cbfd027e..f6ad62bb12 100644--- a/tests/_utils/test_uv_tree.py+++ b/tests/_utils/test_uv_tree.py@@ -29,16 +29,20 @@ def serialize(tree: DependencyTreeNode) -> str:def uv(cmd: list[str], cwd: str | None = None) -> str:assert UV_BIN, "Must have uv installed to use."+ env = {+ **os.environ,+ "UV_PYTHON": "3.13",+ "UV_EXCLUDE_NEWER": "2025-06-19T00:00:00-02:00",+ # Override CI's lowest-direct resolution which can cause uv add to fail+ "UV_RESOLUTION": "highest",+ }result = subprocess.run([UV_BIN] + cmd,check=True,capture_output=True,text=True,cwd=cwd,- env={- "UV_PYTHON": "3.13",- "UV_EXCLUDE_NEWER": "2025-06-19T00:00:00-02:00",- },+ env=env,)return result.stdoutdiff --git a/tests/snapshots/optional-dependencies-sql.txt b/tests/snapshots/optional-dependencies-sql.txtindex d050243cd9..781b8b26a9 100644--- a/tests/snapshots/optional-dependencies-sql.txt+++ b/tests/snapshots/optional-dependencies-sql.txt@@ -1,3 +1,3 @@duckdb>=1.0.0polars[pyarrow]>=1.9.0-sqlglot[c]>=26.2.0\ No newline at end of file+sqlglot[c]>=26.8.0\ No newline at end of file