Skip to content

Commit

Permalink
catch error
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jul 18, 2024
1 parent 44b1a54 commit 686fb9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/textual/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 686fb9c

Please sign in to comment.