Skip to content

Commit f86f480

Browse files
committed
Fix unlabel_rgb raising on a list of colors
1 parent d586d22 commit f86f480

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77
### Fixed
88
- Fix concurrent first access to lazily initialized graph object properties, which could raise `ValueError("Invalid value")` [[#3441](https://github.com/plotly/plotly.py/issues/3441)], with thanks to @hb1915 for the contribution!
99
- Fix `px.sunburst`, `px.treemap` and `px.icicle` listing sectors in a different order on every run when `path` is used with a Polars DataFrame; sectors now follow their order of first appearance for all dataframe backends [[#5765](https://github.com/plotly/plotly.py/issues/5765)], with thanks to @Irahan2 for the contribution!
10+
- Fix `unlabel_rgb` raising `ValueError` on a list of colors even though the documentation states it accepts one; it now returns a list of tuples [[#3054](https://github.com/plotly/plotly.py/issues/3054)]
1011

1112

1213
## [7.1.0] - 2026-09-15

‎_plotly_utils/colors/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ def unlabel_rgb(colors):
728728
This function takes either an 'rgb(a, b, c)' color or a list of
729729
such colors and returns the color tuples in tuple(s) (a, b, c)
730730
"""
731+
if isinstance(colors, (list, tuple)):
732+
return [unlabel_rgb(color) for color in colors]
731733
str_vals = ""
732734
for index in range(len(colors)):
733735
try:

‎tests/test_plotly_utils/colors/test_color_conversions.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ def test_unlabel_rgb_parses_string():
5353
assert unlabel_rgb("rgb(1, 2, 3)") == (1.0, 2.0, 3.0)
5454

5555

56+
def test_unlabel_rgb_parses_list():
57+
# https://github.com/plotly/plotly.py/issues/3054
58+
assert unlabel_rgb(["rgb(255, 0, 0)", "rgb(1, 2, 3)"]) == [
59+
(255.0, 0.0, 0.0),
60+
(1.0, 2.0, 3.0),
61+
]
62+
assert unlabel_rgb([]) == []
63+
64+
5665
def test_label_and_unlabel_are_inverses():
5766
assert unlabel_rgb(label_rgb((10, 20, 30))) == (10.0, 20.0, 30.0)
5867

0 commit comments

Comments
 (0)