diff --git a/CHANGELOG.md b/CHANGELOG.md index 0583fec45c..9d05c377d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - 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! - 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! +- 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)] ## [7.1.0] - 2026-09-15 diff --git a/_plotly_utils/colors/__init__.py b/_plotly_utils/colors/__init__.py index a9689101e6..a0de1bbcce 100644 --- a/_plotly_utils/colors/__init__.py +++ b/_plotly_utils/colors/__init__.py @@ -728,6 +728,8 @@ def unlabel_rgb(colors): This function takes either an 'rgb(a, b, c)' color or a list of such colors and returns the color tuples in tuple(s) (a, b, c) """ + if isinstance(colors, (list, tuple)): + return [unlabel_rgb(color) for color in colors] str_vals = "" for index in range(len(colors)): try: diff --git a/tests/test_plotly_utils/colors/test_color_conversions.py b/tests/test_plotly_utils/colors/test_color_conversions.py index 8e28734b04..78713054db 100644 --- a/tests/test_plotly_utils/colors/test_color_conversions.py +++ b/tests/test_plotly_utils/colors/test_color_conversions.py @@ -53,6 +53,15 @@ def test_unlabel_rgb_parses_string(): assert unlabel_rgb("rgb(1, 2, 3)") == (1.0, 2.0, 3.0) +def test_unlabel_rgb_parses_list(): + # https://github.com/plotly/plotly.py/issues/3054 + assert unlabel_rgb(["rgb(255, 0, 0)", "rgb(1, 2, 3)"]) == [ + (255.0, 0.0, 0.0), + (1.0, 2.0, 3.0), + ] + assert unlabel_rgb([]) == [] + + def test_label_and_unlabel_are_inverses(): assert unlabel_rgb(label_rgb((10, 20, 30))) == (10.0, 20.0, 30.0)