Skip to content

v6.1.0 breaks Pylance highlighting and produces errors #5186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
IlanCosman opened this issue May 16, 2025 · 4 comments · May be fixed by #5198
Open

v6.1.0 breaks Pylance highlighting and produces errors #5186

IlanCosman opened this issue May 16, 2025 · 4 comments · May be fixed by #5198
Assignees
Labels
bug something broken P1 needed for current cycle

Comments

@IlanCosman
Copy link

Code:

import plotly.graph_objects as go

fig = go.Figure(
    data=go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode="lines+markers", name="My Line"),
    layout=go.Layout(
        title=go.layout.Title(text="My Line Chart"),
    ),
)

Expected highlighting / lack of errors (from v6.0.1):

Image

Broken highlight with errors (from v6.1.0):

Image

The error is:

Cannot access attribute "Title" for class "type[FigureWidget]"
  Attribute "Title" is unknownPylance[reportAttributeAccessIssue]

The code of course still runs just fine. I'm using the latest version of VSCode and Pylance at time of writing.

@gvwilson gvwilson added bug something broken P3 backlog labels May 20, 2025
@kszlim
Copy link

kszlim commented May 20, 2025

I'm experiencing this too. I believe everything under plotly.graph_objects is broken in terms of typechecking.

@gvwilson gvwilson added P1 needed for current cycle and removed P3 backlog labels May 20, 2025
@gvwilson gvwilson self-assigned this May 20, 2025
gvwilson added a commit that referenced this issue May 21, 2025
1.  Restore `TYPE_CHECKING` code clauses in `codegen/__init__.py` and `codegen/utils.py`
    that were removed in #4978.
1.  Update `requires-optional.txt` to specify `black==25.1.0` to be consistent with
    version specified in `pyproject.toml`.
1.  Change required Python version in `pyproject.toml` to 3.9 because desired version
    of `black` does not work with Python 3.8.

closes #5186
@emilykl
Copy link
Contributor

emilykl commented May 21, 2025

@IlanCosman @kszlim Thank you for reporting. We've identified the issue and are working on a fix.

We're able to reproduce the broken highlighting (see screenshot below) but can't reproduce the red underline / Cannot access attribute "Title" error -- @kszlim are you seeing that error as well? Is it coming from Pylance or another tool?

Image

@kszlim
Copy link

kszlim commented May 22, 2025

I'm seeing something similar to what you're seeing on vscode with pylance.

gvwilson added a commit that referenced this issue May 22, 2025
-   Restore code removed in #4978.
-   (Partially) closes #5186.
gvwilson added a commit that referenced this issue May 22, 2025
-   Restore code removed in #4978.
-   Finishes closing #5186.
-   Depends on #5198.
@junjiecai
Copy link

junjiecai commented May 23, 2025

Here is what I see in my Cursor for plotly v6.1.0

If I hover on go.Figure or go.Bar, pylance will complain about it

Image

minimal code to reproduce

    from plotly import graph_objects as go
    fig = go.Figure()
    fig.add_trace(
        go.Bar(
            x=[1,2,3],
            y=[1,2,3],
        )
    )

(Environment):
Plotly Version: 6.1.0
Python Version: 3.13.2
Operating System: macOS (Seqonia 15.2)

IDE:
Cursor:Version: 0.50.5(VSCode Version: 1.96.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P1 needed for current cycle
Projects
None yet
5 participants