Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Update `numpy.percentile` syntax to stop using deprecated alias [[5483](https://github.com/plotly/plotly.py/pull/5483)], with thanks to @Mr-Neutr0n for the contribution!
- `numpy` with a version less than 1.22 is no longer supported.
- The `__eq__` method for `graph_objects` classes now returns `NotImplemented` to give the other operand an opportunity to handle the comparison.

## [6.6.0] - 2026-03-02

Expand Down
4 changes: 2 additions & 2 deletions plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def __contains__(self, prop):
def __eq__(self, other):
if not isinstance(other, BaseFigure):
# Require objects to both be BaseFigure instances
return False
return NotImplemented
else:
# Compare plotly_json representations

Expand Down Expand Up @@ -5017,7 +5017,7 @@ def __eq__(self, other):
"""
if not isinstance(other, self.__class__):
# Require objects to be of the same plotly type
return False
return NotImplemented
else:
# Compare plotly_json representations

Expand Down
10 changes: 10 additions & 0 deletions tests/test_core/test_graph_objs/test_figure_properties.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
from unittest.mock import MagicMock
import pytest

import plotly.graph_objs as go
Expand Down Expand Up @@ -42,6 +43,15 @@ def test_contains(self):
def test_iter(self):
self.assertEqual(set(self.figure), {"data", "layout", "frames"})

def test_unsupported_eq_returns_not_implemented(self):
other = MagicMock()
self.assertFalse(self.figure == other)
other.__eq__.assert_called_once_with(self.figure)

other.reset_mock()
self.assertFalse(self.figure.layout == other)
other.__eq__.assert_called_once_with(self.figure.layout)

def test_attr_item(self):
# test that equal objects can be retrieved using attr or item
# syntax
Expand Down