Skip to content

Commit

Permalink
Use string literal types in to_rgba() for matplotlib <3.8 (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru authored Feb 21, 2024
1 parent f5c01de commit 6f6a770
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plotnine/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ def to_rgba(
However :), the colors can be rgba hex values or
list-likes and the alpha dimension will be respected.
"""
from matplotlib.typing import ColorType

def is_iterable(var):
return np.iterable(var) and not isinstance(var, str)
Expand Down Expand Up @@ -608,7 +607,7 @@ def to_rgba_hex(c: ColorType, a: float) -> str:
return c

if is_iterable(colors):
colors = cast(Sequence[ColorType], colors)
colors = cast(Sequence["ColorType"], colors)

if all(no_color(c) for c in colors):
return "none"
Expand All @@ -618,7 +617,7 @@ def to_rgba_hex(c: ColorType, a: float) -> str:
else:
return [to_rgba_hex(c, alpha) for c in colors]
else:
colors = cast(ColorType, colors)
colors = cast("ColorType", colors)

if no_color(colors):
return colors
Expand Down

0 comments on commit 6f6a770

Please sign in to comment.