Skip to content

Commit 6276c39

Browse files
committed
Make Color a union type of 3/4-tuple of floats and str
1 parent fb3e4c7 commit 6276c39

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

lib/matplotlib/_color_data.pyi

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ._typing import Color
2+
3+
BASE_COLORS: dict[str, Color]
4+
TABLEAU_COLORS: dict[str, Color]
5+
XKCD_COLORS: dict[str, Color]
6+
CSS4_COLORS: dict[str, Color]

lib/matplotlib/axis.pyi

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ from matplotlib.transforms import Transform, Bbox
99

1010
import datetime
1111
from typing import Any, Literal, Type, Iterable, Callable
12+
from matplotlib._typing import Color
1213
import numpy as np
1314
from numpy.typing import ArrayLike
1415

15-
# TODO actually type colors
16-
Color = Any
1716

1817
GRIDLINE_INTERPOLATION_STEPS: int
1918

lib/matplotlib/figure.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ class FigureBase(Artist):
235235
) -> Bbox: ...
236236

237237
# Any in list of list is recursive list[list[Hashable | list[Hashable | ...]]] but that can't really be type checked
238-
# TODO: add per_subplot_kw
239238
def subplot_mosaic(
240239
self,
241240
mosaic: str | list[list[Any]],

lib/matplotlib/pyplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def figure(
761761
# defaults to rc figure.facecolor
762762
facecolor: Color | None = None,
763763
# defaults to rc figure.edgecolor
764-
edgecolor: Color = None,
764+
edgecolor: Color | None = None,
765765
frameon: bool = True,
766766
FigureClass: Type[Figure] = Figure,
767767
clear: bool = False,

lib/matplotlib/spines.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Spine(mpatches.Patch):
6060
def circular_spine(
6161
cls: Type[T], axes: Axes, center: tuple[float, float], radius: float, **kwargs
6262
) -> T: ...
63-
def set_color(self, c: Color) -> None: ...
63+
def set_color(self, c: Color | None) -> None: ...
6464

6565
class SpinesProxy:
6666
def __init__(self, spine_dict: dict[str, Spine]) -> None: ...

0 commit comments

Comments
 (0)