Skip to content

[Feature Request] Better static type checking support #3428

@janosh

Description

@janosh

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 astral-sh/ty#1135 (comment) 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogfeaturesomething new

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions