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.

fix: ensure "async " only appears once in async function signatures (#7091)

Peter Bygrave6ba411b740a8
diff --git a/marimo/_plugins/stateless/inspect.py b/marimo/_plugins/stateless/inspect.py
index ed9b06a7b8..053a720549 100644
--- a/marimo/_plugins/stateless/inspect.py
+++ b/marimo/_plugins/stateless/inspect.py
@@ -256,9 +256,7 @@ def _get_object_title(obj: object) -> tuple[str, str]:
def _get_signature(obj: object) -> str | None:
try:
- sig = inspect_.signature(obj) # type: ignore
- prefix = "async " if inspect_.iscoroutinefunction(obj) else ""
- return f"{prefix}{sig}"
+ return str(inspect_.signature(obj)) # type: ignore
except (ValueError, TypeError):
return None
diff --git a/tests/_plugins/stateless/test_inspect.py b/tests/_plugins/stateless/test_inspect.py
index 4e0bd30679..c273cce69b 100644
--- a/tests/_plugins/stateless/test_inspect.py
+++ b/tests/_plugins/stateless/test_inspect.py
@@ -28,6 +28,11 @@ def simple_function(x: int, y: str = "default") -> str:
return f"{x} - {y}"
+async def async_function(a: int) -> int:
+ """Double the value."""
+ return a * 2
+
+
def test_inspect_basic_object() -> None:
obj = SimpleClass()
result = inspect(obj)
@@ -59,6 +64,13 @@ def test_inspect_function() -> None:
assert "str" in html
+def test_inspect_async_function() -> None:
+ result = inspect(async_function)
+ html = result.text
+
+ assert "async def async_function(" in html
+
+
def test_inspect_with_methods() -> None:
obj = SimpleClass()
result = inspect(obj, methods=True)