Skip to content

add_vline fails in batch mode #4742

Description

@dejfh

I am using plotly 5.24.0 with python 3.10.12 in a vs-code interactive window.

The following example raises TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str' in [...]/site-packages/plotly/basedatatypes.py:3995

import plotly.graph_objects as go

fig = go.Figure()

with fig.batch_update():
    fig.add_vline(1)

The same example without batch mode works fine:

import plotly.graph_objects as go

fig = go.Figure()

fig.add_vline(1)

Activity

  1. added
    bugsomething broken
    P2considered for next cycle
    P3backlog
    and removed
    P2considered for next cycle
    on Sep 3, 2024
  2. sOnU1002 commented on Oct 2, 2024

    @sOnU1002

    Minimum Working Example (MWE):
    Here is a minimal example that reproduces the issue:

    python
    Copy code
    import plotly.graph_objects as go

    fig = go.Figure()

    Raises TypeError when used in batch mode

    with fig.batch_update():
    fig.add_vline(1)
    When batch_update() is removed, the code works fine:

    python
    Copy code
    import plotly.graph_objects as go

    fig = go.Figure()

    Works without batch mode

    fig.add_vline(1)
    Expected Behavior:
    The add_vline() method should be compatible with the batch_update() context and should not raise any errors. The vertical line should be added while benefitting from the performance improvements of batch mode.

    Actual Behavior:
    When the add_vline() method is called within batch_update(), a TypeError is raised, which appears to be related to appending a NoneType to a string at line 3995 in basedatatypes.py of Plotly's internal code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions