"Unexpected keyword argument" when using flexible callback signature

I’m experiencing an off issue when using the now-not-so-new Flexible Callback Signature feature of Dash 2.x.

Here is my code:

@app.callback(
       output=[Output("test", "children")],
       inputs={ 'a': Input('control-complexity-slider', 'value') }
)
def display(all_inputs):
    return [all_inputs]

This returns the following error:

Callback error updating ..test.children..
TypeError: display() got an unexpected keyword argument 'a'

Whereas the following works:

@app.callback(
    output=[Output("test", "children")],
    inputs=[ Input('control-complexity-slider', 'value') ]
)
def display(all_inputs):
    return [all_inputs]

I’m not quite sure how my first snippet differs from the documentation at Flexible Callback Signatures | Dash for Python Documentation | Plotly

@app.callback(
    output=[Output(...), Output(...)],
    inputs=dict(
        ab=(Input(...), Input(...)),
        c=Input(...)
    )
)
def callback(ab, c):
    a, b = ab
    return [a + b, b + c]

Answering my own question. RTFM…
In this case, the order of the callback's function arguments doesn't matter. All that matters is that the keys of the dependency dictionary match the function argument names

So, corrected:

@app.callback(
       output=[Output("test", "children")],
       inputs={ 'all_inputs': Input('control-complexity-slider', 'value') }
)
def display(all_inputs):
    return [all_inputs]
1 Like