plotly / plotly/dash

[BUG] Remaining Typing/Mypy errors after Dash 3.0.2 to Dash 3.0.4 upgrade

Open
#3,292 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The following minimum example:

from typing import Any

from dash import Dash, html, dash_table, dcc

app = Dash()

app.layout = html.Div(
    [
        html.H3("Initial Title", id="my-title"),
        html.Div(
            dash_table.DataTable(
                id="table",
                columns=[
                    {"name": "Type", "id": "Type"},
                    {"name": "Processed", "id": "Processed"},
                    {"name": "Start", "id": "Start"},
                    {"name": "End", "id": "End"},
                ],
                style_cell={"textAlign": "left"},
                filter_action="native",
                sort_action="native",
            ),
        ),
    ],
    className="topmenu",
    role="button",
    **{"aria-pressed": "false"},
)


class MyGraph(dcc.Graph):
    """Subclass of dash_core_components.Graph to remove modeBarButtons"""

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(
            *args,
            **kwargs,
            config=dict(modeBarButtonsToRemove=["sendDataToCloud"]),
        )

Generates no issues with mypy 1.15.0 and Dash 3.0.2. Then upgrading to Dash 3.0.4

(venv) PS C:\Users\gxvh\Python\dash_mypy> mypy
Success: no issues found in 1 source file
(venv) PS C:\Users\gxvh\Python\dash_mypy> poetry update
Updating dependencies
Resolving dependencies... (54.3s)

Package operations: 0 installs, 1 update, 0 removals

  - Updating dash (3.0.2 -> 3.0.4)

Writing lock file
(venv) PS C:\Users\gxvh\Python\dash_mypy> mypy
dash_test.py:11: error: Module has no attribute "DataTable"  [attr-defined]
dash_test.py:27: error: Argument 4 to "Div" has incompatible type "**dict[str, str]"; expected "SupportsFloat | SupportsInt | SupportsComplex | None"  [arg-type]
dash_test.py:27: error: Argument 4 to "Div" has incompatible type "**dict[str, str]"; expected "bool | None"  [arg-type]
dash_test.py:27: error: Argument 4 to "Div" has incompatible type "**dict[str, str]"; expected "Literal['hidden', 'HIDDEN'] | bool | None"  [arg-type]
dash_test.py:35: error: "__init__" of "Graph" gets multiple values for keyword argument "config"  [misc]
Found 5 errors in 1 file (checked 1 source file)
(venv) PS C:\Users\gxvh\Python\dash_mypy>

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

Start by running the supplied minimum example with mypy 1.15.0 against Dash 3.0.4 and compare it with Dash 3.0.2. Investigate the typing changes behind DataTable, aria-pressed, and Graph config. Done means the five reported errors are resolved without changing the example's intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.