File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1346,6 +1346,10 @@ def check_fn_match_arg_spec(
1346
1346
EventFnArgMismatch: Raised if the number of mandatory arguments do not match
1347
1347
"""
1348
1348
user_args = inspect .getfullargspec (user_func ).args
1349
+ # Drop the first argument if it's a bound method
1350
+ if inspect .ismethod (user_func ) and user_func .__self__ is not None :
1351
+ user_args = user_args [1 :]
1352
+
1349
1353
user_default_args = inspect .getfullargspec (user_func ).defaults
1350
1354
number_of_user_args = len (user_args ) - number_of_bound_args
1351
1355
number_of_user_default_args = len (user_default_args ) if user_default_args else 0
Original file line number Diff line number Diff line change 2
2
3
3
import pytest
4
4
5
+ import reflex as rx
5
6
from reflex .event import (
6
7
Event ,
7
8
EventChain ,
@@ -439,3 +440,17 @@ def _args_spec(value: Var[int]) -> tuple[Var[int]]:
439
440
# Ensure chain carries _var_data
440
441
chain_var = Var .create (EventChain (events = [S .s (S .x )], args_spec = _args_spec ))
441
442
assert chain_var ._get_all_var_data () == S .x ._get_all_var_data ()
443
+
444
+
445
+ def test_event_bound_method () -> None :
446
+ class S (BaseState ):
447
+ @event
448
+ def e (self , arg : str ):
449
+ print (arg )
450
+
451
+ class Wrapper :
452
+ def get_handler (self , arg : str ):
453
+ return S .e (arg )
454
+
455
+ w = Wrapper ()
456
+ _ = rx .input (on_change = w .get_handler )
You can’t perform that action at this time.
0 commit comments