dash
dash copied to clipboard
[Feature Request] Better static type checking support
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
Thanks @janosh - we don't have resources to put against this right now, but would be happy to prioritize a community PR.