From 686fb9cbebd18667fd7506284d14e7667e9f5702 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 18 Jul 2024 15:55:55 +0100 Subject: [PATCH] catch error --- src/textual/color.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/textual/color.py b/src/textual/color.py index bd77654533..69e0eecb8d 100644 --- a/src/textual/color.py +++ b/src/textual/color.py @@ -600,8 +600,10 @@ def from_colors(cls, *colors: Color | str, quality: int = 50) -> Gradient: quality: The number of steps in the gradient. Returns: - _type_: _description_ + A new Gradient instance. """ + if len(colors) < 2: + raise ValueError("Two or more colors required.") stops = [(i / (len(colors) - 1), Color.parse(c)) for i, c in enumerate(colors)] return cls(*stops, quality=quality)