Skip to content

[BUG]: Figure.__eq__ returns False for unsupported comparisons #5546

@RazerM

Description

@RazerM

Description

Python's rich comparison methods should return NotImplemented so that the RHS of a comparison is given the opportunity to implement the comparison.

In my case, I have a test snapshot fixture such that I can do assert figure == snapshot.

Screenshots/Video

N/A

Steps to reproduce

import plotly.graph_objects as go


class MyObject:
    def __eq__(self, other):
        print(f"MyObject.__eq__({other!r}) called")
        return NotImplemented

print(1 == MyObject())
print(go.Figure() == MyObject())
MyObject.__eq__(1) called
False
False

There should be a print of MyObject.__eq__(Figure({...})) called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions