dash icon indicating copy to clipboard operation
dash copied to clipboard

[Feature Request] Better static type checking support

Open janosh opened this issue 6 months ago • 1 comments

running ty check ty-issue-1135.py raises a type error:

# ty-issue-1135.py
import dash

dropdown = dash.dcc.Dropdown(
    id="dropdown",
    options=list(range(5))
)

dropdown.id  # error[unresolved-attribute] Type `Dropdown` has no attribute `id`

as @carljm proposed in https://github.com/astral-sh/ty/issues/1135#issuecomment-3259155919 since the body of classes like dash.dcc.Dropdown is auto-generated

... it wouldn't be hard for dash to also generate a id: typing.Optional[typing.Union[str, dict]] annotation on the class body (not just in the __init__ signature) -- that would resolve the problem.

where the problem is that neither pyright nor mypy nor ty understand the attributes present on dash.dcc.Dropdown and other dash classes

janosh avatar Sep 05 '25 18:09 janosh

Thanks @janosh - we don't have resources to put against this right now, but would be happy to prioritize a community PR.

gvwilson avatar Sep 09 '25 12:09 gvwilson