Skip to content

[BUG] isinstance(fig, go.Figure) raises TypeError after activating plotly-resamplerΒ #364

@Blubbaa

Description

@Blubbaa

Describe the bug πŸ–οΈ
After calling register_plotly_resampler(mode="auto"), using isinstance(fig, go.Figure) raises a TypeError instead of returning a boolean. This breaks downstream code that validates figure instances with isinstance().

Reproducing the bug πŸ”

import numpy as np
import plotly.graph_objects as go
from plotly.graph_objs._figure import Figure
from plotly_resampler import register_plotly_resampler

if __name__ == "__main__":
    # Before registration, this works fine
    fig = go.Figure()
    print(isinstance(fig, go.Figure))  # True

    # After registration, this raises TypeError
    register_plotly_resampler(mode="auto")
    fig = go.Figure()
    print(isinstance(fig, go.Figure))  # TypeError!
    print(isinstance(fig, Figure))     # This would work but requires downstream code changes

Expected behavior πŸ”§
isinstance(fig, go.Figure) should return True even after register_plotly_resampler() has been called, since FigureResampler should be a subclass of go.Figure.

Environment information:

  • OS: Windows
  • Python environment:
    • Python version: Python 3.13.11
    • plotly-resampler environment: Issue persists both in Python scripts and Jupyter
  • plotly-resampler version: 0.11.0

Additional context
Workaround requires importing the private Figure class directly. This forces consumers to either use the private API or modify their validation logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions