You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pyright rejects @rx.event(...) stacked above another @rx.event, although the repeated decorator is supported at runtime #7847
Since #7807, stacking @rx.event decorators is supported at runtime: a repeated decorator is merged into one handler (options of the outer decorator win), which keeps apps like reflex-examples overkey working. The type stubs do not follow: the EventDecorator protocol that rx.event(...) returns only accepts a plain function Callable[[BASE_STATE, Unpack[P]], Any]. Applied to the EventCallback that the inner @rx.event produces, pyright reports an argument-type error on the decorator line. The unit tests for #7807 carry # pyright: ignore for this reason.
Repro
importreflexasrxclassS(rx.State):
count: int=0@rx.event(throttle=300) # pyright: error (argument of type EventCallback[int] not assignable to Callable[[BASE_STATE, ...], Any])@rx.event(background=True)asyncdeftick(self, step: int):
asyncwithself:
self.count+=step
uv run pyright on a file containing this (pyright 1.1.41x). The bare form @rx.event above @rx.event(...) goes through the func overload of rx.event; check it too.
Expected vs actual
Expected: no pyright error; S.tick is typed EventCallback[int], like a single decorator.
Actual: pyright error on the outer decorator.
Fix direction
Code: EventDecorator.__call__ and the EventNamespace.__new__ overloads in packages/reflex-base/src/reflex_base/event/__init__.py.
Add an overload of EventDecorator.__call__ that accepts EventCallback[Unpack[P]] and returns EventCallback[Unpack[P]]; if the bare func overload of rx.event has the same gap, add the matching overload there.
Remove the # pyright: ignore comments from the repeated-decorator tests in tests/units/test_event.py once they pass, and add a typing check in the typing test suite if one exists for event handlers.
Not a regression (stacking crashed at import before #7807).
Activity
linear-code commentedon Nov 11, 2026
ENG-13995