plotly / plotly/dash

[Feature Request] Better static type checking support

Open
#3,428 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run ty check ty-issue-1135.py to reproduce the unresolved-attribute error, then inspect how dash.dcc.Dropdown and other Dash classes are auto-generated. Done means generated class bodies expose attributes such as id so pyright, mypy, and ty no longer report them as unresolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.