22from abc import ABC
33
44from .callback import Callback
5- from .channel import Channel
5+ from .channel import Input , State , Output
66
77
88class Contribution (ABC ):
@@ -20,7 +20,7 @@ class Contribution(ABC):
2020 """
2121
2222 # noinspection PyShadowingBuiltins
23- def __init__ (self , name : str , ** initial_state ):
23+ def __init__ (self , name : str , ** initial_state : Any ):
2424 self .name = name
2525 self .initial_state = initial_state
2626 self .extension : str | None = None
@@ -47,7 +47,7 @@ def to_dict(self) -> dict[str, Any]:
4747 d .update (callbacks = [cb .to_dict () for cb in self .callbacks ])
4848 return d
4949
50- def layout (self , * args ) -> Callable [[Callable ], Callable ]:
50+ def layout (self , * args : State ) -> Callable [[Callable ], Callable ]:
5151 """Provides a decorator for a user-provided function that
5252 returns the initial user interface layout.
5353
@@ -65,13 +65,12 @@ def layout(self, *args) -> Callable[[Callable], Callable]:
6565 called `ctx`.
6666
6767 Other parameters of the decorated function are user-defined
68- and must have a corresponding `chartlets.Input` or
69- `chartlets.State` arguments in the `layout` decorator in the
70- same order.
68+ and must have a corresponding `chartlets.State` arguments
69+ in the `layout` decorator in the same order.
7170
7271 Args:
7372 args:
74- `chartlets.Input` or `chartlets. State` objects that
73+ `chartlets.State` objects that
7574 define the source of the value for the corresponding
7675 parameter of the decorated function. Optional.
7776
@@ -81,13 +80,13 @@ def layout(self, *args) -> Callable[[Callable], Callable]:
8180
8281 def decorator (function : Callable ) -> Callable :
8382 self .layout_callback = Callback .from_decorator (
84- "layout" , args , function , outputs_allowed = False
83+ "layout" , args , function , states_only = True
8584 )
8685 return function
8786
8887 return decorator
8988
90- def callback (self , * args : Channel ) -> Callable [[Callable ], Callable ]:
89+ def callback (self , * args : Input | State | Output ) -> Callable [[Callable ], Callable ]:
9190 """Provide a decorator for a user-provided callback function.
9291
9392 Callback functions are event handlers that react
@@ -125,7 +124,7 @@ def callback(self, *args: Channel) -> Callable[[Callable], Callable]:
125124 def decorator (function : Callable ) -> Callable :
126125 self .callbacks .append (
127126 Callback .from_decorator (
128- "callback" , args , function , outputs_allowed = True
127+ "callback" , args , function , states_only = False
129128 )
130129 )
131130 return function
0 commit comments