dash icon indicating copy to clipboard operation
dash copied to clipboard

[BUG] incorrect typing of `options` in `Dropdown`

Open mathause opened this issue 4 months ago • 1 comments

Describe your context

dash                      3.2.0
dash-bootstrap-components 2.0.4
dash-extensions           2.0.4
dash-svg                  0.0.12

Describe the bug

Passing a list-of-dict can be passed to options of dcc.Dropdown but is not allowed by the types:

error: Argument "options" to "Dropdown" has incompatible type "list[dict[str, str]]"; expected "Sequence[str | SupportsFloat | SupportsInt | SupportsComplex | bool] | dict[Any, Any] | Sequence[Options] | None"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

Expected behavior

Allow Sequence[dict[...]]

MVCE

# dropdown_tying.py

from dash import Dash, dcc, html, Input, Output,callback


options = [
       {'label': 'New York City', 'value': 'NYC'},
       {'label': 'Montreal', 'value': 'MON'},
       {'label': 'San Francisco', 'value': 'SF'},
   ]


app = Dash()
app.layout = html.Div([
    dcc.Dropdown(options=options, value='NYC', id='demo-dropdown'),
    html.Div(id='dd-output-container')
])


@callback(
    Output('dd-output-container', 'children'),
    Input('demo-dropdown', 'value')
)
def update_output(value):
    return f'You have selected {value}'


if __name__ == '__main__':
    app.run(debug=True)
mypy dropdown_tying.py

mathause avatar Oct 28 '25 08:10 mathause

I ran this both in dash 3.2.0 and dash 4.0.0rc2 and can confirm that the Dropdown typing error for the options prop is fixed in dash 4.

AnnMarieW avatar Nov 13 '25 15:11 AnnMarieW