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
chore(ruff): enable explicit pytest regex checks (#10857)
Shahmir Varqha9f9ee0c38639
diff --git a/pyproject.toml b/pyproject.tomlindex b48c047c62..272bd43cab 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -383,7 +383,6 @@ ignore = [# Restored to Ruff's default rule set in 0.16.6; enable incrementally"RUF069", # Float equality comparison"PLW0108", # Unnecessary lambda- "RUF043", # Ambiguous pattern in `pytest.raises`"RUF065", # Eager conversion in logging calls"PLC2801", # Unnecessary dunder call"FURB189", # Subclassing built-in collectionsdiff --git a/tests/_ast/test_load.py b/tests/_ast/test_load.pyindex e5554aed96..e6d7779133 100644--- a/tests/_ast/test_load.py+++ b/tests/_ast/test_load.py@@ -285,7 +285,7 @@ class TestGetCodes:@staticmethoddef test_get_codes_non_marimo_python_script() -> None:with pytest.raises(- NonMarimoPythonScriptError, match="is not a marimo notebook."+ NonMarimoPythonScriptError, match=r"is not a marimo notebook\."):load.load_app(get_filepath("test_get_codes_non_marimo_python_script")diff --git a/tests/_ast/test_parse.py b/tests/_ast/test_parse.pyindex eb194120fc..6625f9f70f 100644--- a/tests/_ast/test_parse.py+++ b/tests/_ast/test_parse.py@@ -200,7 +200,7 @@ class TestParser:# Non-marimo files that have marimo imports but no App definition# should raise MarimoFileError with the expected messagewith pytest.raises(- MarimoFileError, match="`marimo.App` definition expected."+ MarimoFileError, match=r"`marimo\.App` definition expected\."):parse_notebook(get_filepath("test_non_marimo").read_text())diff --git a/tests/_code_mode/test_plan_building.py b/tests/_code_mode/test_plan_building.pyindex 62b772af06..2cac94f5f8 100644--- a/tests/_code_mode/test_plan_building.py+++ b/tests/_code_mode/test_plan_building.py@@ -214,7 +214,7 @@ class TestCombined:class TestValidation:def test_delete_and_update_same_cell(self) -> None:- with pytest.raises(ValueError, match="delete.*update"):+ with pytest.raises(ValueError, match=r"delete.*update"):_validate_ops([_UpdateOp(cell_id=CellId_t("a"), code="x"),@@ -223,7 +223,7 @@ class TestValidation:)def test_update_and_delete_same_cell(self) -> None:- with pytest.raises(ValueError, match="update.*delete"):+ with pytest.raises(ValueError, match=r"update.*delete"):_validate_ops([_DeleteOp(cell_id=CellId_t("a")),@@ -232,7 +232,7 @@ class TestValidation:)def test_delete_and_move_same_cell(self) -> None:- with pytest.raises(ValueError, match="delete.*move"):+ with pytest.raises(ValueError, match=r"delete.*move"):_validate_ops([_MoveOp(cell_id=CellId_t("a"), after=CellId_t("b")),diff --git a/tests/_environments/test_environment.py b/tests/_environments/test_environment.pyindex 34d0c2f22d..6815653c7f 100644--- a/tests/_environments/test_environment.py+++ b/tests/_environments/test_environment.py@@ -77,7 +77,7 @@ def test_old_uv_is_rejected(stub.chmod(stub.stat().st_mode | stat.S_IEXEC)monkeypatch.setenv("UV", str(stub))- with pytest.raises(UvUnsupportedVersionError, match="0.5.0"):+ with pytest.raises(UvUnsupportedVersionError, match=r"0\.5\.0"):sync(str(tmp_path / "nb.py"))diff --git a/tests/_mcp/code_server/test_code_server.py b/tests/_mcp/code_server/test_code_server.pyindex 38b6ad8ac6..83ddb26cce 100644--- a/tests/_mcp/code_server/test_code_server.py+++ b/tests/_mcp/code_server/test_code_server.py@@ -69,7 +69,7 @@ def test_code_mcp_server_requires_supported_mcp_version(monkeypatch):with pytest.raises(MarimoCLIMissingDependencyError,- match="MCP SDK 1.9.0 is not supported",+ match=r"MCP SDK 1\.9\.0 is not supported",):setup_code_mcp_server(Starlette())diff --git a/tests/_mcp/server/test_mcp_server.py b/tests/_mcp/server/test_mcp_server.pyindex 4cd5079c16..2b3e25a11c 100644--- a/tests/_mcp/server/test_mcp_server.py+++ b/tests/_mcp/server/test_mcp_server.py@@ -62,7 +62,7 @@ def test_mcp_server_requires_supported_mcp_version(monkeypatch):with pytest.raises(MarimoCLIMissingDependencyError,- match="MCP SDK 1.9.0 is not supported",+ match=r"MCP SDK 1\.9\.0 is not supported",):setup_mcp_server(Starlette())diff --git a/tests/_messaging/notebook/test_document.py b/tests/_messaging/notebook/test_document.pyindex d0bccc0424..b9f8b9adcc 100644--- a/tests/_messaging/notebook/test_document.py+++ b/tests/_messaging/notebook/test_document.py@@ -326,7 +326,7 @@ class TestMoveCell:def test_no_anchor_raises(self) -> None:doc = _doc("a", "b")- with pytest.raises(ValueError, match="before.*after"):+ with pytest.raises(ValueError, match=r"before.*after"):doc.apply(_tx(MoveCell(cell_id=CellId_t("a"))))def test_missing_cell_raises(self) -> None:@@ -580,7 +580,7 @@ class TestSetConfig:class TestValidation:def test_delete_and_set_code_same_cell(self) -> None:doc = _doc("a")- with pytest.raises(ValueError, match="delete.*update"):+ with pytest.raises(ValueError, match=r"delete.*update"):doc.apply(_tx(SetCode(cell_id=CellId_t("a"), code="x"),@@ -590,7 +590,7 @@ class TestValidation:def test_set_code_and_delete_same_cell(self) -> None:doc = _doc("a")- with pytest.raises(ValueError, match="update.*delete"):+ with pytest.raises(ValueError, match=r"update.*delete"):doc.apply(_tx(DeleteCell(cell_id=CellId_t("a")),@@ -600,7 +600,7 @@ class TestValidation:def test_delete_and_move_same_cell(self) -> None:doc = _doc("a", "b")- with pytest.raises(ValueError, match="delete.*move"):+ with pytest.raises(ValueError, match=r"delete.*move"):doc.apply(_tx(MoveCell(cell_id=CellId_t("a"), after=CellId_t("b")),diff --git a/tests/_plugins/stateless/status/test_progress.py b/tests/_plugins/stateless/status/test_progress.pyindex d39f5f8fd0..a9e2d6a3c2 100644--- a/tests/_plugins/stateless/status/test_progress.py+++ b/tests/_plugins/stateless/status/test_progress.py@@ -214,7 +214,7 @@ def test_progress_no_total_error():with pytest.raises(TypeError,- match="Cannot determine the length of a collection. A `total` must be provided.",+ match=r"Cannot determine the length of a collection\. A `total` must be provided\.",):progress_bar(sync_generator())@@ -229,7 +229,7 @@ def test_progress_async_no_total_error():with pytest.raises(TypeError,- match="Cannot determine the length of a collection. A `total` must be provided.",+ match=r"Cannot determine the length of a collection\. A `total` must be provided\.",):progress_bar(async_generator())@@ -242,7 +242,7 @@ def test_progress_for_loop_error():with pytest.raises(RuntimeError,- match="Cannot iterate over an async collection with `for`. Use `async for` instead.",+ match=r"Cannot iterate over an async collection with `for`\. Use `async for` instead\.",):for _ in progress_bar(async_generator(), total=1):pass@@ -253,7 +253,7 @@ async def test_progress_async_for_loop_error():with pytest.raises(RuntimeError,- match="Cannot iterate over a sync collection with `async for`. Use `for` instead.",+ match=r"Cannot iterate over a sync collection with `async for`\. Use `for` instead\.",):async for _ in progress_bar([1, 2, 3]):passdiff --git a/tests/_plugins/ui/_impl/dataframes/test_filter_model.py b/tests/_plugins/ui/_impl/dataframes/test_filter_model.pyindex dfdb5f6113..904db9e39b 100644--- a/tests/_plugins/ui/_impl/dataframes/test_filter_model.py+++ b/tests/_plugins/ui/_impl/dataframes/test_filter_model.py@@ -160,7 +160,7 @@ def test_condition_between_range_value_passthrough() -> None:def test_condition_between_missing_min() -> None:- with pytest.raises(ValueError, match="min.*max"):+ with pytest.raises(ValueError, match=r"min.*max"):FilterCondition(type="condition",column_id="x",@@ -170,7 +170,7 @@ def test_condition_between_missing_min() -> None:def test_condition_between_missing_max() -> None:- with pytest.raises(ValueError, match="min.*max"):+ with pytest.raises(ValueError, match=r"min.*max"):FilterCondition(type="condition",column_id="x",diff --git a/tests/_plugins/ui/_impl/test_batch.py b/tests/_plugins/ui/_impl/test_batch.pyindex 21929c32e1..29cd94c1fb 100644--- a/tests/_plugins/ui/_impl/test_batch.py+++ b/tests/_plugins/ui/_impl/test_batch.py@@ -14,17 +14,17 @@ from marimo._plugins.ui._impl.batch import validate_and_clonedef test_batch_rejects_non_ui_elements() -> None:"""Test that batch raises ValueError for non-UIElement arguments."""with pytest.raises(- ValueError, match="`.batch` only accepts UIElements as arguments"+ ValueError, match=r"`\.batch` only accepts UIElements as arguments"):md("Example {thing}").batch(thing="thing") # type: ignorewith pytest.raises(- ValueError, match="`.batch` only accepts UIElements as arguments"+ ValueError, match=r"`\.batch` only accepts UIElements as arguments"):md("Example {thing}").batch(thing=42) # type: ignorewith pytest.raises(- ValueError, match="`.batch` only accepts UIElements as arguments"+ ValueError, match=r"`\.batch` only accepts UIElements as arguments"):md("Example {thing}").batch(thing={"key": "value"}) # type: ignore@@ -32,17 +32,17 @@ def test_batch_rejects_non_ui_elements() -> None:def test_dictionary_rejects_non_ui_elements() -> None:"""Test that dictionary raises ValueError for non-UIElement arguments."""with pytest.raises(- ValueError, match="`.batch` only accepts UIElements as arguments"+ ValueError, match=r"`\.batch` only accepts UIElements as arguments"):ui.dictionary({"hi": 1}) # type: ignorewith pytest.raises(- ValueError, match="`.batch` only accepts UIElements as arguments"+ ValueError, match=r"`\.batch` only accepts UIElements as arguments"):ui.dictionary({"text": "string"}) # type: ignorewith pytest.raises(- ValueError, match="`.batch` only accepts UIElements as arguments"+ ValueError, match=r"`\.batch` only accepts UIElements as arguments"):ui.dictionary({"valid": ui.slider(1, 10), "invalid": "string"}) # type: ignorediff --git a/tests/_plugins/ui/_impl/test_matrix.py b/tests/_plugins/ui/_impl/test_matrix.pyindex a6d8b01100..7d81736e7e 100644--- a/tests/_plugins/ui/_impl/test_matrix.py+++ b/tests/_plugins/ui/_impl/test_matrix.py@@ -168,17 +168,17 @@ def test_matrix_empty_row_raises():def test_matrix_step_zero_raises():- with pytest.raises(ValueError, match="step.*positive"):+ with pytest.raises(ValueError, match=r"step.*positive"):ui.matrix([[1]], step=0)def test_matrix_step_negative_raises():- with pytest.raises(ValueError, match="step.*positive"):+ with pytest.raises(ValueError, match=r"step.*positive"):ui.matrix([[1]], step=-0.5)def test_matrix_step_per_element_zero_raises():- with pytest.raises(ValueError, match="step.*positive"):+ with pytest.raises(ValueError, match=r"step.*positive"):ui.matrix([[1, 2]], step=[[1, 0]])@@ -416,12 +416,12 @@ def test_matrix_1d_value_above_max_raises():def test_matrix_1d_step_zero_raises():- with pytest.raises(ValueError, match="step.*positive"):+ with pytest.raises(ValueError, match=r"step.*positive"):ui.matrix([1], step=0)def test_matrix_1d_step_negative_raises():- with pytest.raises(ValueError, match="step.*positive"):+ with pytest.raises(ValueError, match=r"step.*positive"):ui.matrix([1], step=-0.5)@@ -443,7 +443,7 @@ def test_matrix_1d_2d_param_raises():def test_matrix_1d_symmetric_raises():"""symmetric=True with 1D input should raise."""- with pytest.raises(ValueError, match="symmetric.*not supported.*1D"):+ with pytest.raises(ValueError, match=r"symmetric.*not supported.*1D"):ui.matrix([1, 2], symmetric=True)diff --git a/tests/_runtime/test_wasm_multiprocessing_pool.py b/tests/_runtime/test_wasm_multiprocessing_pool.pyindex 2454537b92..31e623ef7f 100644--- a/tests/_runtime/test_wasm_multiprocessing_pool.py+++ b/tests/_runtime/test_wasm_multiprocessing_pool.py@@ -102,7 +102,7 @@ def test_wasm_pool_context_and_submodule_factories() -> None:with pytest.raises(UnsupportedWasmConcurrencyError,- match="multiprocessing.pool.ThreadPool",+ match=r"multiprocessing\.pool\.ThreadPool",):pool_module.ThreadPool(1)finally:diff --git a/tests/_runtime/test_wasm_threading.py b/tests/_runtime/test_wasm_threading.pyindex 3411b5ad85..5022b123e6 100644--- a/tests/_runtime/test_wasm_threading.py+++ b/tests/_runtime/test_wasm_threading.py@@ -179,9 +179,9 @@ def test_wasm_threading_local_dict_is_read_only() -> None:local.value = 1assert local.__dict__ == {"value": 1}- with pytest.raises(AttributeError, match="__dict__.*read-only"):+ with pytest.raises(AttributeError, match=r"__dict__.*read-only"):local.__dict__ = {}- with pytest.raises(AttributeError, match="__dict__.*read-only"):+ with pytest.raises(AttributeError, match=r"__dict__.*read-only"):del local.__dict__assert local.__dict__ == {"value": 1}finally:diff --git a/tests/_save/test_signing.py b/tests/_save/test_signing.pyindex 5afabb3356..4859dbb8a0 100644--- a/tests/_save/test_signing.py+++ b/tests/_save/test_signing.py@@ -167,7 +167,7 @@ class TestSignVerify:"""Truncated/corrupted base64 in the signature string raises CacheSignatureError."""_, verifier = _make_verifier()with pytest.raises(- CacheSignatureError, match="not readable|corrupted"+ CacheSignatureError, match=r"not readable|corrupted"):verifier.verify(b"data", "not!!valid==base64@@")