Skip to content

[BUG] incorrect typing of options in Dropdown #3487

@mathause

Description

@mathause

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

Metadata

Metadata

Assignees

Labels

P2considered for next cyclebugsomething broken

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions