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.

Utility class for fn that take 0 args (#233)

Akshay Agrawal4e22a2cffafd
diff --git a/marimo/_runtime/functions.py b/marimo/_runtime/functions.py
index 3c53ae37a8..752e8f2d7d 100644
--- a/marimo/_runtime/functions.py
+++ b/marimo/_runtime/functions.py
@@ -13,6 +13,12 @@ S = TypeVar("S")
T = TypeVar("T")
+class EmptyArgs:
+ """Utility type for functions that take no arguments."""
+ ...
+
+
@dataclasses.dataclass
class Function(Generic[S, T]):
name: str
diff --git a/marimo/_utils/test_parse_dataclass.py b/marimo/_utils/test_parse_dataclass.py
index 59b9653cd3..469854e584 100644
--- a/marimo/_utils/test_parse_dataclass.py
+++ b/marimo/_utils/test_parse_dataclass.py
@@ -7,7 +7,7 @@ from typing import Any, Dict, List, Tuple
from marimo._server import api
from marimo._server.api.set_cell_config import SetCellConfig
-from marimo._utils.parse_dataclass import parse_raw
+from marimo._utils.parse_dataclass import build_dataclass, parse_raw
@dataclass
@@ -124,5 +124,13 @@ class TestParseRaw:
parsed = parse_raw(
serialize(config), api.set_cell_config.SetCellConfig
)
- print(parsed)
assert parsed == config
+
+
+def test_build_empty_dataclass() -> None:
+ @dataclass
+ class Empty:
+ ...
+
+ parsed = build_dataclass({}, Empty)
+ assert parsed == Empty()