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
fix: preserve Python callback scheduling types (#11487)
Shahmir Varqha5cfa101e379e
diff --git a/marimo/_utils/debounce.py b/marimo/_utils/debounce.pyindex 7c9fb33ecb..25dee5ffce 100644--- a/marimo/_utils/debounce.py+++ b/marimo/_utils/debounce.py@@ -2,30 +2,34 @@from __future__ import annotationsimport time-from collections.abc import Callablefrom functools import wraps-from typing import Any, TypeVar, cast+from typing import TYPE_CHECKING, ParamSpec-F = TypeVar("F", bound=Callable[..., None])+if TYPE_CHECKING:+ from collections.abc import Callable+P = ParamSpec("P")-def debounce(wait_time: float) -> Callable[[F], F]:++def debounce(+ wait_time: float,+) -> Callable[[Callable[P, None]], Callable[P, None]]:"""Decorator to prevent a function from being called more than once everywait_time seconds."""- def decorator(func: F) -> F:+ def decorator(func: Callable[P, None]) -> Callable[P, None]:last_called: float = 0@wraps(func)- def wrapped(*args: Any, **kwargs: Any) -> None:+ def wrapped(*args: P.args, **kwargs: P.kwargs) -> None:nonlocal last_calledcurrent_time = time.time()if current_time - last_called >= wait_time:last_called = current_timefunc(*args, **kwargs)- return cast(F, wrapped)+ return wrappedreturn decoratordiff --git a/marimo/_utils/distributor.py b/marimo/_utils/distributor.pyindex 1c4d27977d..068c0b1563 100644--- a/marimo/_utils/distributor.py+++ b/marimo/_utils/distributor.py@@ -5,7 +5,7 @@ import asyncioimport threadingimport timefrom collections.abc import Callable-from typing import Any, Generic, Protocol, TypeVar+from typing import Generic, Protocol, TypeVarfrom marimo import _loggersfrom marimo._session.queue import QueueType@@ -27,7 +27,7 @@ class Distributor(Protocol, Generic[T_co]):"""Add a consumer to the distributor."""...- def start(self) -> Any:+ def start(self) -> Disposable | threading.Thread:"""Start the distributor."""...