Skip to content

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.

chore: use ruff to auto add returns (#1143)

Myles Scolnicke232fb381d9c
diff --git a/pyproject.toml b/pyproject.toml
index e2daf9f45c..addba05df8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -144,6 +144,7 @@ exclude = [
"marimo/_smoke_tests",
"marimo/_test_utils/codegen_data",
"marimo/_test_utils/_tutorials",
+ "marimo/_static/files/wasm-intro.py",
"tests/_ast/codegen_data",
"tests/_ast/cell_data",
"tests/_cli/ipynb_data",
@@ -176,6 +177,12 @@ extend-select = [
"ARG",
# flake8-bugbear
"B",
+ "ANN002", # missing-type-args
+ "ANN003", # missing-type-kwargs
+ "ANN201", # missing-return-type-undocumented-public-function
+ "ANN202", # missing-return-type-private-function
+ "ANN205", # missing-return-type-static-method
+ "ANN206", # missing-return-type-class-method
# future annotations
"FA102",
# isort
@@ -210,6 +217,9 @@ extend-select = [
"TRY002", # Prohibit use of `raise Exception`, use specific exceptions instead.
]
+[tool.ruff.lint.per-file-ignores]
+"**/{tests}/*" = ["ANN201", "ANN202"]
+
# Never try to fix `F401` (unused imports).
unfixable = ["F401"]
diff --git a/tests/_ast/test_app.py b/tests/_ast/test_app.py
index a22de11bcb..3907e26afa 100644
--- a/tests/_ast/test_app.py
+++ b/tests/_ast/test_app.py
@@ -82,11 +82,11 @@ class TestApp:
app = App()
@app.cell
- def one():
+ def one() -> None:
x = y # noqa: F841, F821
@app.cell
- def two():
+ def two() -> None:
y = x # noqa: F841, F821
with pytest.raises(CycleError):
@@ -114,11 +114,11 @@ class TestApp:
app = App()
@app.cell
- def one():
+ def one() -> None:
x = 0 # noqa: F841
@app.cell
- def two():
+ def two() -> None:
x = 0 # noqa: F841
with pytest.raises(MultipleDefinitionError):
@@ -129,11 +129,11 @@ class TestApp:
app = App()
@app.cell
- def one():
+ def one() -> None:
x = 0 # noqa: F841
@app.cell
- def two():
+ def two() -> None:
del x # noqa: F841, F821
with pytest.raises(DeleteNonlocalError):
@@ -342,7 +342,7 @@ class TestApp:
@app.cell
def __() -> tuple[Any]:
- def foo(): ...
+ def foo() -> None: ...
return (foo,)
diff --git a/tests/_ast/test_cell.py b/tests/_ast/test_cell.py
index 6774501f45..a8ede5410d 100644
--- a/tests/_ast/test_cell.py
+++ b/tests/_ast/test_cell.py
@@ -151,7 +151,7 @@ class TestCellRun:
app = App()
@app.cell
- def f():
+ def f() -> None:
return
assert f.run() == (None, {})
@@ -191,12 +191,12 @@ def help_smoke() -> None:
app = App()
@app.cell
- async def f(x):
+ async def f(x) -> None:
await x
return
@app.cell
- def g():
+ def g() -> None:
return
assert "Async" in f._help().text
diff --git a/tests/_plugins/ui/_impl/test_data_explorer.py b/tests/_plugins/ui/_impl/test_data_explorer.py
index fea4e01a8d..79d0f4fb8c 100644
--- a/tests/_plugins/ui/_impl/test_data_explorer.py
+++ b/tests/_plugins/ui/_impl/test_data_explorer.py
@@ -11,7 +11,7 @@ HAS_DEPS = DependencyManager.has_pandas()
@pytest.mark.skipif(not HAS_DEPS, reason="optional dependencies not installed")
-def test_data_explorer(executing_kernel: Kernel):
+def test_data_explorer(executing_kernel: Kernel) -> None:
# unused, except for the side effect of giving the kernel an execution
# context
del executing_kernel
diff --git a/tests/_runtime/test_marimo_pdb.py b/tests/_runtime/test_marimo_pdb.py
index 4b760a263d..62334413ff 100644
--- a/tests/_runtime/test_marimo_pdb.py
+++ b/tests/_runtime/test_marimo_pdb.py
@@ -3,7 +3,7 @@ from marimo._runtime.runtime import Kernel
from tests.conftest import ExecReqProvider
-async def test_pdb_patched(k: Kernel, exec_req: ExecReqProvider):
+async def test_pdb_patched(k: Kernel, exec_req: ExecReqProvider) -> None:
await k.run([exec_req.get("import pdb")])
pdb = k.globals["pdb"]
diff --git a/tests/_runtime/test_query_params.py b/tests/_runtime/test_query_params.py
index 1d073761ca..2a18d3e460 100644
--- a/tests/_runtime/test_query_params.py
+++ b/tests/_runtime/test_query_params.py
@@ -6,46 +6,46 @@ from marimo._runtime.query_params import QueryParams
class TestQueryParams(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
self.mock_stream = MagicMock(spec=Stream)
self.params = QueryParams(
{"key1": "value1", "key2": ["value2", "value3"]},
stream=self.mock_stream,
)
- def test_get(self):
+ def test_get(self) -> None:
assert self.params.get("key1") == "value1"
assert self.params.get("key2") == ["value2", "value3"]
- def test_get_all(self):
+ def test_get_all(self) -> None:
assert self.params.get_all("key1") == ["value1"]
assert self.params.get_all("key2") == ["value2", "value3"]
assert self.params.get_all("non_existent_key") == []
- def test_contains(self):
+ def test_contains(self) -> None:
assert "key1" in self.params
assert "non_existent_key" not in self.params
- def test_len(self):
+ def test_len(self) -> None:
assert len(self.params) == 2
- def test_iter(self):
+ def test_iter(self) -> None:
keys = [key for key in self.params]
assert keys, ["key1", "key2"]
- def test_repr(self):
+ def test_repr(self) -> None:
assert (
repr(self.params)
== "QueryParams({'key1': 'value1', 'key2': ['value2', 'value3']})"
)
- def test_str(self):
+ def test_str(self) -> None:
assert (
str(self.params)
== "{'key1': 'value1', 'key2': ['value2', 'value3']}"
)
- def test_setitem(self):
+ def test_setitem(self) -> None:
self.params["key3"] = "value4"
assert self.params.get("key3") == "value4"
@@ -55,7 +55,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key3", "value": "value4"},
}
- def test_setitem_null(self):
+ def test_setitem_null(self) -> None:
self.params["key1"] = None # type: ignore
assert self.params.get("key1") is None
@@ -65,7 +65,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key1", "value": None},
}
- def test_setitem_empty(self):
+ def test_setitem_empty(self) -> None:
self.params["key1"] = []
assert self.params.get("key1") is None
@@ -75,7 +75,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key1", "value": None},
}
- def test_set(self):
+ def test_set(self) -> None:
self.params.set("key1", "value5")
assert self.params.get("key1") == "value5"
@@ -85,7 +85,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key1", "value": "value5"},
}
- def test_set_null(self):
+ def test_set_null(self) -> None:
self.params.set("key1", None) # type: ignore
assert self.params.get("key1") is None
@@ -95,7 +95,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key1", "value": None},
}
- def test_set_empty(self):
+ def test_set_empty(self) -> None:
self.params.set("key1", [])
assert self.params.get("key1") is None
@@ -105,7 +105,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key1", "value": None},
}
- def test_append(self):
+ def test_append(self) -> None:
self.params.append("key1", "value5")
assert self.params.get("key1") == ["value1", "value5"]
self.params.append("key4", "value6")
@@ -121,7 +121,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key4", "value": "value6"},
}
- def test_delete(self):
+ def test_delete(self) -> None:
del self.params["key1"]
assert "key1" not in self.params
assert len(self.params) == 1
@@ -151,7 +151,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key2", "value": None},
}
- def test_remove(self):
+ def test_remove(self) -> None:
self.params.remove("key2", "value2")
assert self.params.get("key2") == ["value3"]
self.params.remove("key2")
@@ -169,7 +169,7 @@ class TestQueryParams(unittest.TestCase):
"data": {"key": "key2", "value": None},
}
- def test_clear(self):
+ def test_clear(self) -> None:
self.params.clear()
assert len(self.params) == 0
assert str(self.params) == "{}"
diff --git a/tests/_runtime/test_runtime.py b/tests/_runtime/test_runtime.py
index 152593d0b2..b5a0e47998 100644
--- a/tests/_runtime/test_runtime.py
+++ b/tests/_runtime/test_runtime.py
@@ -866,7 +866,7 @@ async def test_set_ui_element_value_with_cell_run(
assert k.globals["counter"][0] == 1
-def test_sys_path_updated(tmp_path: pathlib.Path):
+def test_sys_path_updated(tmp_path: pathlib.Path) -> None:
main: ModuleType | None = None
try:
filename = str(tmp_path / "notebook.py")
diff --git a/tests/_server/api/endpoints/test_resume_session.py b/tests/_server/api/endpoints/test_resume_session.py
index 68d1e8f2b8..43c0f6a8f9 100644
--- a/tests/_server/api/endpoints/test_resume_session.py
+++ b/tests/_server/api/endpoints/test_resume_session.py
@@ -44,7 +44,7 @@ HEADERS = {
def assert_kernel_ready_response(
raw_data: dict[str, Any], response: dict[str, Any]
-):
+) -> None:
data = parse_raw(raw_data["data"], KernelReady)
expected = parse_raw(response, KernelReady)
assert data.cell_ids == expected.cell_ids
diff --git a/tests/_server/files/test_os_file_system.py b/tests/_server/files/test_os_file_system.py
index 2618ed8886..563ebae78f 100644
--- a/tests/_server/files/test_os_file_system.py
+++ b/tests/_server/files/test_os_file_system.py
@@ -9,17 +9,17 @@ from marimo._server.models.files import FileDetailsResponse
class TestOSFileSystem(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
# Create a temporary directory for the tests
self.temp_dir = TemporaryDirectory()
self.test_dir = self.temp_dir.name
self.fs = OSFileSystem()
- def tearDown(self):
+ def tearDown(self) -> None:
# Cleanup the temporary directory after each test
self.temp_dir.cleanup()
- def test_create_file(self):
+ def test_create_file(self) -> None:
test_file_name = "test_file.txt"
self.fs.create_file_or_directory(
self.test_dir, "file", test_file_name, None
@@ -27,7 +27,7 @@ class TestOSFileSystem(unittest.TestCase):
expected_path = os.path.join(self.test_dir, test_file_name)
assert os.path.exists(expected_path)
- def test_create_file_with_duplicate_name(self):
+ def test_create_file_with_duplicate_name(self) -> None:
test_file_name = "test_file.txt"
self.fs.create_file_or_directory(
self.test_dir, "file", test_file_name, None
@@ -40,7 +40,7 @@ class TestOSFileSystem(unittest.TestCase):
expected_path = os.path.join(self.test_dir, "test_file_1.txt")
assert os.path.exists(expected_path)
- def test_create_directory(self):
+ def test_create_directory(self) -> None:
test_dir_name = "test_dir"
self.fs.create_file_or_directory(
self.test_dir, "directory", test_dir_name, None
@@ -48,29 +48,29 @@ class TestOSFileSystem(unittest.TestCase):
expected_path = os.path.join(self.test_dir, test_dir_name)
assert os.path.isdir(expected_path)
- def test_create_with_empty_name(self):
+ def test_create_with_empty_name(self) -> None:
with pytest.raises(ValueError):
self.fs.create_file_or_directory(self.test_dir, "file", "", None)
- def test_create_with_disallowed_name(self):
+ def test_create_with_disallowed_name(self) -> None:
with pytest.raises(ValueError):
self.fs.create_file_or_directory(self.test_dir, "file", ".", None)
- def test_list_files(self):
+ def test_list_files(self) -> None:
# Create a test file and directory
self.test_create_file()
self.test_create_directory()
files = self.fs.list_files(self.test_dir)
assert len(files) == 2 # Expecting 1 file and 1 directory
- def test_list_files_with_broken_directory_symlink(self):
+ def test_list_files_with_broken_directory_symlink(self) -> None:
# Create a broken symlink
broken_symlink = os.path.join(self.test_dir, "broken_symlink")
os.symlink("non_existent_file", broken_symlink)
files = self.fs.list_files(self.test_dir)
assert len(files) == 0
- def test_get_details(self):
+ def test_get_details(self) -> None:
test_file_name = "test_file.txt"
self.fs.create_file_or_directory(
self.test_dir,
@@ -86,7 +86,7 @@ class TestOSFileSystem(unittest.TestCase):
assert file_info.mime_type == "text/plain"
assert file_info.contents == "some content"
- def test_get_details_marimo_file(self):
+ def test_get_details_marimo_file(self) -> None:
test_file_name = "app.py"
content = """
import marimo
@@ -108,7 +108,7 @@ class TestOSFileSystem(unittest.TestCase):
assert isinstance(file_info, FileDetailsResponse)
assert file_info.file.is_marimo_file
- def test_open_file(self):
+ def test_open_file(self) -> None:
test_file_name = "test_file.txt"
test_content = "Hello, World!"
with open(os.path.join(self.test_dir, test_file_name), "w") as f:
@@ -118,7 +118,7 @@ class TestOSFileSystem(unittest.TestCase):
)
assert content == test_content
- def test_delete_file(self):
+ def test_delete_file(self) -> None:
test_file_name = "test_file.txt"
file_path = os.path.join(self.test_dir, test_file_name)
with open(file_path, "w"):
@@ -126,7 +126,7 @@ class TestOSFileSystem(unittest.TestCase):
self.fs.delete_file_or_directory(file_path)
assert not os.path.exists(file_path)
- def test_move_file(self):
+ def test_move_file(self) -> None:
original_file_name = "original.txt"
new_file_name = "new.txt"
original_path = os.path.join(self.test_dir, original_file_name)
@@ -137,7 +137,7 @@ class TestOSFileSystem(unittest.TestCase):
assert os.path.exists(new_path)
assert not os.path.exists(original_path)
- def test_move_with_disallowed_name(self):
+ def test_move_with_disallowed_name(self) -> None:
original_file_name = "original.txt"
new_file_name = "."
original_path = os.path.join(self.test_dir, original_file_name)
@@ -147,7 +147,7 @@ class TestOSFileSystem(unittest.TestCase):
with pytest.raises(ValueError):
self.fs.move_file_or_directory(original_path, new_path)
- def test_update_file(self):
+ def test_update_file(self) -> None:
test_file_name = "test_file.txt"
file_path = os.path.join(self.test_dir, test_file_name)
with open(file_path, "w") as f:
diff --git a/tests/_server/session/test_session_view.py b/tests/_server/session/test_session_view.py
index 04c7c13a25..62d73188da 100644
--- a/tests/_server/session/test_session_view.py
+++ b/tests/_server/session/test_session_view.py
@@ -120,7 +120,7 @@ def test_session_view_variable_values() -> None:
assert list(variables_names) == ["var2"]
-def test_ui_values():
+def test_ui_values() -> None:
session_view = SessionView()
session_view.add_control_request(
SetUIElementValueRequest([("test_ui", 123)])
@@ -150,7 +150,7 @@ def test_ui_values():
assert "test_ui3" in session_view.ui_values
-def test_last_run_code():
+def test_last_run_code() -> None:
session_view = SessionView()
session_view.add_control_request(
ExecuteMultipleRequest(
@@ -187,7 +187,7 @@ def test_last_run_code():
assert session_view.last_executed_code[cell_id] == "print('hello')"
-def test_add_variables():
+def test_add_variables() -> None:
session_view = SessionView()
session_view.add_raw_operation(
@@ -221,7 +221,7 @@ def test_add_variables():
assert session_view.variable_values["var2"].value == "hello"
-def test_add_cell_op():
+def test_add_cell_op() -> None:
session_view = SessionView()
session_view.add_raw_operation(
serialize(
diff --git a/tests/_server/templates/test_templates.py b/tests/_server/templates/test_templates.py
index 7cd34e5346..ffb4c6751e 100644
--- a/tests/_server/templates/test_templates.py
+++ b/tests/_server/templates/test_templates.py
@@ -17,7 +17,7 @@ snapshot = snapshotter(__file__)
class TestNotebookPageTemplate(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
root = os.path.realpath(
os.path.join(os.path.dirname(__file__), "data")
)
@@ -32,7 +32,7 @@ class TestNotebookPageTemplate(unittest.TestCase):
self.filename = "notebook.py"
self.mode = SessionMode.RUN
- def test_notebook_page_template(self):
+ def test_notebook_page_template(self) -> None:
result = templates.notebook_page_template(
self.html,
self.base_url,
@@ -48,7 +48,7 @@ class TestNotebookPageTemplate(unittest.TestCase):
assert self.filename in result
assert "read" in result
- def test_notebook_page_template_no_filename(self):
+ def test_notebook_page_template_no_filename(self) -> None:
result = templates.notebook_page_template(
self.html,
self.base_url,
@@ -64,7 +64,7 @@ class TestNotebookPageTemplate(unittest.TestCase):
assert "<title>marimo</title>" in result
assert "read" in result
- def test_notebook_page_template_edit_mode(self):
+ def test_notebook_page_template_edit_mode(self) -> None:
result = templates.notebook_page_template(
self.html,
self.base_url,
@@ -82,7 +82,7 @@ class TestNotebookPageTemplate(unittest.TestCase):
class TestHomePageTemplate(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
root = os.path.realpath(
os.path.join(os.path.dirname(__file__), "data")
)
@@ -94,7 +94,7 @@ class TestHomePageTemplate(unittest.TestCase):
self.user_config = DEFAULT_CONFIG
self.server_token = "token"
- def test_home_page_template(self):
+ def test_home_page_template(self) -> None:
result = templates.home_page_template(
self.html,
self.base_url,
@@ -112,7 +112,7 @@ class TestHomePageTemplate(unittest.TestCase):
class TestStaticNotebookTemplate(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
root = os.path.realpath(
os.path.join(os.path.dirname(__file__), "data")
)
@@ -156,7 +156,7 @@ class TestStaticNotebookTemplate(unittest.TestCase):
}
self.files = {"file1": "File 1 content", "file2": "File 2 content"}
- def test_static_notebook_template(self):
+ def test_static_notebook_template(self) -> None:
result = templates.static_notebook_template(
self.html,
self.user_config,
@@ -175,7 +175,7 @@ class TestStaticNotebookTemplate(unittest.TestCase):
snapshot("export1.txt", normalize_index_html(result))
- def test_static_notebook_template_no_filename(self):
+ def test_static_notebook_template_no_filename(self) -> None:
result = templates.static_notebook_template(
self.html,
self.user_config,
@@ -194,7 +194,7 @@ class TestStaticNotebookTemplate(unittest.TestCase):
snapshot("export2.txt", normalize_index_html(result))
- def test_static_notebook_template_no_code(self):
+ def test_static_notebook_template_no_code(self) -> None:
result = templates.static_notebook_template(
self.html,
self.user_config,
diff --git a/tests/_server/test_asgi.py b/tests/_server/test_asgi.py
index e1f9628ae0..eefa13f0fc 100644
--- a/tests/_server/test_asgi.py
+++ b/tests/_server/test_asgi.py
@@ -26,7 +26,7 @@ if __name__ == "__main__":
class TestASGIAppBuilder(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
# Create a temporary directory for the tests
self.temp_dir = tempfile.TemporaryDirectory()
self.app1 = os.path.join(self.temp_dir.name, "app1.py")
@@ -36,11 +36,11 @@ class TestASGIAppBuilder(unittest.TestCase):
with open(self.app2, "w") as f:
f.write(contents.replace("placeholder", "app2"))
- def tearDown(self):
+ def tearDown(self) -> None:
# Clean up the temporary directory
self.temp_dir.cleanup()
- def test_create_asgi_app(self):
+ def test_create_asgi_app(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
assert isinstance(builder, ASGIAppBuilder)
@@ -51,7 +51,7 @@ class TestASGIAppBuilder(unittest.TestCase):
app = builder.build()
assert callable(app)
- def test_app_base(self):
+ def test_app_base(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/", root=self.app1)
app = builder.build()
@@ -60,7 +60,7 @@ class TestASGIAppBuilder(unittest.TestCase):
assert response.status_code == 200
assert "app1.py" in response.text
- def test_app_redirect(self):
+ def test_app_redirect(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/test", root=self.app1)
app = builder.build()
@@ -69,7 +69,7 @@ class TestASGIAppBuilder(unittest.TestCase):
assert response.status_code == 200, response.text
assert "app1.py" in response.text
- def test_multiple_apps(self):
+ def test_multiple_apps(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/app1", root=self.app1)
builder = builder.with_app(path="/app2", root=self.app2)
@@ -86,7 +86,7 @@ class TestASGIAppBuilder(unittest.TestCase):
response = client.get("/app3")
assert response.status_code == 404, response.text
- def test_root_doesnt_conflict_when_root_is_last(self):
+ def test_root_doesnt_conflict_when_root_is_last(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/app1", root=self.app1)
builder = builder.with_app(path="/", root=self.app2)
@@ -99,7 +99,7 @@ class TestASGIAppBuilder(unittest.TestCase):
assert response.status_code == 200, response.text
assert "app2.py" in response.text
- def test_root_doesnt_conflict_when_root_is_first(self):
+ def test_root_doesnt_conflict_when_root_is_first(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/", root=self.app2)
builder = builder.with_app(path="/app1", root=self.app1)
@@ -112,7 +112,7 @@ class TestASGIAppBuilder(unittest.TestCase):
assert response.status_code == 200, response.text
assert "app2.py" in response.text
- def test_can_include_code(self):
+ def test_can_include_code(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/app1", root=self.app1)
app = builder.build()
@@ -121,7 +121,7 @@ class TestASGIAppBuilder(unittest.TestCase):
assert response.status_code == 200, response.text
assert "app1.py" in response.text
- def test_can_hit_health(self):
+ def test_can_hit_health(self) -> None:
builder = create_asgi_app(quiet=True, include_code=True)
builder = builder.with_app(path="/app1", root=self.app1)
app = builder.build()
diff --git a/tests/_server/test_session_manager.py b/tests/_server/test_session_manager.py
index 419a702908..19ee7e7744 100644
--- a/tests/_server/test_session_manager.py
+++ b/tests/_server/test_session_manager.py
@@ -35,7 +35,7 @@ def session_manager():
)
-def test_start_lsp_server(session_manager: SessionManager):
+def test_start_lsp_server(session_manager: SessionManager) -> None:
asyncio.get_event_loop().run_until_complete(
session_manager.start_lsp_server()
)
@@ -44,7 +44,7 @@ def test_start_lsp_server(session_manager: SessionManager):
def test_create_session_new(
session_manager: SessionManager, mock_session_consumer: SessionConsumer
-):
+) -> None:
session_id = "test_session_id"
session = session_manager.create_session(
session_id,
@@ -62,7 +62,7 @@ def test_create_session_absolute_url(
session_manager: SessionManager,
mock_session_consumer: SessionConsumer,
temp_marimo_file: str,
-):
+) -> None:
session_id = "test_session_id"
session = session_manager.create_session(
session_id,
@@ -78,7 +78,7 @@ def test_create_session_absolute_url(
def test_maybe_resume_session_for_new_file(
session_manager: SessionManager, mock_session: Session
-):
+) -> None:
session_id = "test_session_id"
mock_session.connection_state.return_value = ConnectionState.ORPHANED
mock_session.app_file_manager = AppFileManager(filename=None)
@@ -108,7 +108,7 @@ def test_maybe_resume_session_for_existing_file(
session_manager: SessionManager,
mock_session: Session,
temp_marimo_file: str,
-):
+) -> None:
session_id = "test_session_id"
mock_session.connection_state.return_value = ConnectionState.ORPHANED
mock_session.app_file_manager = AppFileManager(filename=temp_marimo_file)
@@ -134,7 +134,9 @@ def test_maybe_resume_session_for_existing_file(
assert resumed_session is mock_session
-def test_close_session(session_manager: SessionManager, mock_session: Session):
+def test_close_session(
+ session_manager: SessionManager, mock_session: Session
+) -> None:
session_id = "test_session_id"
session_manager.sessions[session_id] = mock_session
session_manager.close_session(session_id)
@@ -144,7 +146,7 @@ def test_close_session(session_manager: SessionManager, mock_session: Session):
def test_any_clients_connected_new_file(
session_manager: SessionManager, mock_session: Session
-):
+) -> None:
session_id = "test_session_id"
session_manager.sessions[session_id] = mock_session
mock_session.app_file_manager = AppFileManager(filename=None)
@@ -158,7 +160,7 @@ def test_any_clients_connected_existing_file(
session_manager: SessionManager,
mock_session: Session,
temp_marimo_file: str,
-):
+) -> None:
session_id = "test_session_id"
session_manager.sessions[session_id] = mock_session
mock_session.app_file_manager = AppFileManager(filename=temp_marimo_file)
@@ -171,7 +173,7 @@ def test_any_clients_connected_existing_file(
def test_close_all_sessions(
session_manager: SessionManager, mock_session: Session
-):
+) -> None:
session_manager.sessions = {
"session1": mock_session,
"session2": mock_session,
@@ -181,7 +183,9 @@ def test_close_all_sessions(
assert mock_session.close.call_count == 2
-def test_shutdown(session_manager: SessionManager, mock_session: Session):
+def test_shutdown(
+ session_manager: SessionManager, mock_session: Session
+) -> None:
session_manager.sessions = {
"session1": mock_session,
"session2": mock_session,
diff --git a/tests/_server/test_sessions.py b/tests/_server/test_sessions.py
index e2d2783c6f..b28531eae6 100644
--- a/tests/_server/test_sessions.py
+++ b/tests/_server/test_sessions.py
@@ -26,7 +26,7 @@ app_metadata = AppMetadata(
def save_and_restore_main(f):
"""Kernels swap out the main module; restore it after running tests"""
- def wrapper():
+ def wrapper() -> None:
main = sys.modules["__main__"]
try:
f()
diff --git a/tests/_utils/test_decorator.py b/tests/_utils/test_decorator.py
index 919d848192..797c490a89 100644
--- a/tests/_utils/test_decorator.py
+++ b/tests/_utils/test_decorator.py
@@ -7,9 +7,9 @@ from marimo._utils.debounce import debounce
call_count = 0
-def test_debounce_within_period():
+def test_debounce_within_period() -> None:
@debounce(wait_time=1.5)
- def my_function():
+ def my_function() -> None:
global call_count
call_count += 1
@@ -24,9 +24,9 @@ def test_debounce_within_period():
assert call_count == 1
-def test_debounce_after_period():
+def test_debounce_after_period() -> None:
@debounce(wait_time=0.1)
- def my_function():
+ def my_function() -> None:
global call_count
call_count += 1
diff --git a/tests/_utils/test_disposable.py b/tests/_utils/test_disposable.py
index 165816aa4c..9fc7360618 100644
--- a/tests/_utils/test_disposable.py
+++ b/tests/_utils/test_disposable.py
@@ -1,10 +1,10 @@
from marimo._utils.disposable import Disposable
-def test_disposable():
+def test_disposable() -> None:
was_action_called = False
- def action():
+ def action() -> None:
nonlocal was_action_called
was_action_called = True
@@ -15,7 +15,7 @@ def test_disposable():
assert disposable.is_disposed()
-def test_disposable_empty():
+def test_disposable_empty() -> None:
empty_disposable = Disposable.empty()
assert not empty_disposable.is_disposed()
empty_disposable.dispose()
diff --git a/tests/_utils/test_file_watcher.py b/tests/_utils/test_file_watcher.py
index bebfed91f3..0d565148f2 100644
--- a/tests/_utils/test_file_watcher.py
+++ b/tests/_utils/test_file_watcher.py
@@ -11,7 +11,7 @@ from marimo._utils.file_watcher import PollingFileWatcher
@pytest.mark.asyncio
-async def test_polling_file_watcher():
+async def test_polling_file_watcher() -> None:
with NamedTemporaryFile(delete=False) as tmp_file:
tmp_path = Path(tmp_file.name)
diff --git a/tests/conftest.py b/tests/conftest.py
index a28be0653c..f3ac799a49 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -105,7 +105,7 @@ class MockedKernel:
stream=self.stream, # type: ignore
)
- def teardown(self):
+ def teardown(self) -> None:
# must be called by fixtures that instantiate this
teardown_context()
self.stdout._watcher.stop()