-
Notifications
You must be signed in to change notification settings - Fork 919
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
TypeIs and TypeGuard functions wrapped in @app.function do not respect type hints when called, when other functions decorated with functools.wraps do. See:
Will you submit a PR?
- Yes
Environment
Details
{
"marimo": "0.19.11",
"editable": false,
"location": "C:/Users/Andrew/Code/project/code/.venv/Lib/site-packages/marimo",
"OS": "Windows",
"OS Version": "11",
"Processor": "Intel64 Family 6 Model 141 Stepping 1, GenuineIntel",
"Python Version": "3.13.9",
"Locale": "--",
"Binaries": {
"Browser": "--",
"Node": "v22.15.1",
"uv": "0.9.26 (ee4f00362 2026-01-15)"
},
"Dependencies": {
"click": "8.2.1",
"docutils": "0.22",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.8.2",
"narwhals": "2.2.0",
"packaging": "25.0",
"psutil": "7.0.0",
"pygments": "2.19.2",
"pymdown-extensions": "10.16.1",
"pyyaml": "6.0.2",
"starlette": "0.47.3",
"tomlkit": "0.13.3",
"typing-extensions": "4.15.0",
"uvicorn": "0.35.0",
"websockets": "15.0.1"
},
"Optional Dependencies": {
"altair": "6.0.0",
"duckdb": "1.3.2",
"loro": "1.10.3",
"mcp": "1.18.0",
"nbformat": "5.10.4",
"openai": "2.15.0",
"pandas": "2.3.2",
"polars": "1.32.3",
"pyarrow": "21.0.0",
"pytest": "8.4.1",
"python-lsp-ruff": "2.2.2",
"python-lsp-server": "1.13.1",
"ruff": "0.12.11",
"sqlglot": "27.9.0",
"vegafusion": "2.0.3",
"watchdog": "6.0.0"
},
"Experimental Flags": {}
}
Code to reproduce
from functools import wraps
from typing import Any, TypeIs
import marimo
app = marimo.App()
def wraps_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
@wraps_decorator
def type_is_int(x: Any) -> TypeIs[int]:
return isinstance(x, int)
@app.function
def mo_type_is_int(x: Any) -> TypeIs[int]:
return isinstance(x, int)
var: dict | int = {}
if type_is_int(var):
var += 1
else:
var |= {"key": "value"}
if mo_type_is_int(var):
var += 1
else:
var |= {"key": "value"}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working