Getting started with callbacks; input and state need list or tuple prior to version 1.14.0

Hi,

thanks for the great community edition.

I just notice that the tutorial here:

https://dash.plotly.com/basic-callbacks

doesn’t wrap input or state arguments for the callback in square brackets. The way it is now it didn’t work me.

Might need an update or did I do sth wrong?

Cheers

Are you getting any errors? The callbacks should work fine even if you don’t wrap the inputs and states into square brackets.

ye, something like this:

[...]site-packages/dash/_validate.py", line 22, in validate_callback_args
    raise exceptions.IncorrectTypeException(
dash.exceptions.IncorrectTypeException: The input argument `btn.n_clicks` must be a list or tuple of
`dash.dependencies.Input`s.

Can you share the code block of your callback function?

without square brackets i get the above error

@app.callback(
    Output('groom_table', 'children'),
    [Input('groombtn', 'n_clicks')],
    [State('IntervalChoser', 'value'),
    State('DurationChoser', 'value')]
    )

The callback decorator looks fine the Output, Input and State are correctly written too, what about the function? Their is 1 input and 2 states in your callback so your function definition should also have the same number of parameters.
Like this:

def do_something(nclicks, n1, n2):

it of course has :slight_smile:

as i said, with the square brackets it works perfectly fine.

thanks for the debugging advice, but i am fine with how it is now. just in case somebody has the same problem he might stumble upon this post here and hopefully it helps him/her!

1 Like

Thanks to @AnnMarieW for bringing it to my notice that you won’t need to use lists in the callback - that hasn’t been required since 1.14.0.

1 Like