8000 Add (color, alpha) tuple as a valid ColorType · matplotlib/matplotlib@dd98207 · GitHub
[go: up one dir, main page]

Skip to content

Commit dd98207

Browse files
committed
Add (color, alpha) tuple as a valid ColorType
Introduced by #24691, merged shortly before #24976 Not totally sold on the name 'RawColorType', but couldn't think of something I like better Noticed that one of the other type aliases was not documented, so fixed that while I was editing these two files
1 parent a844eca commit dd98207

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ repos:
1717
hooks:
1818
- id: check-added-large-files
1919
- id: check-docstring-first
20+
exclude: lib/matplotlib/typing.py # docstring used for attribute flagged by check
2021
- id: end-of-file-fixer
2122
exclude_types: [svg]
2223
- id: mixed-line-ending

doc/api/typing_api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
``matplotlib.typing``
33
*********************
44

5+
.. autodata:: matplotlib.typing.RawColorType
6+
.. autodata:: matplotlib.typing.RawColourType
57
.. autodata:: matplotlib.typing.ColorType
68
.. autodata:: matplotlib.typing.ColourType
79
.. autodata:: matplotlib.typing.LineStyleType
810
.. autodata:: matplotlib.typing.DrawStyleType
911
.. autodata:: matplotlib.typing.MarkEveryType
1012
.. autodata:: matplotlib.typing.FillStyleType
1113
.. autodata:: matplotlib.typing.RcStyleType
14+
.. autodata:: matplotlib.typing.HashableList
15+
:annotation: Nested list with Hashable values

lib/matplotlib/typing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
# The following are type aliases. Once python 3.9 is dropped, they should be annotated
2020
# using ``typing.TypeAlias`` and Unions should be converted to using ``|`` syntax.
2121

22-
ColorType = Union[tuple[float, float, float], tuple[float, float, float, float], str]
22+
RawColorType = Union[tuple[float, float, float], tuple[float, float, float, float], str]
23+
RawColourType = RawColorType
24+
25+
ColorType = Union[RawColorType, tuple[RawColorType, float]]
2326
ColourType = ColorType
2427

2528
LineStyleType = Union[str, tuple[float, Sequence[float]]]
@@ -43,3 +46,4 @@
4346
]
4447

4548
HashableList = list[Union[Hashable, "HashableList"]]
49+
"""A nested list of Hashable values."""

0 commit comments

Comments
 (0)
0