-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
/
typing.py
60 lines (48 loc) · 2.05 KB
/
typing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
Typing support for Matplotlib
This module contains Type aliases which are useful for Matplotlib and potentially
downstream libraries.
.. admonition:: Provisional status of typing
The ``typing`` module and type stub files are considered provisional and may change
at any time without a deprecation period.
"""
from collections.abc import Hashable, Sequence
import pathlib
from typing import Any, Literal, TypeVar, Union
from . import path
from ._enums import JoinStyle, CapStyle
from .markers import MarkerStyle
# The following are type aliases. Once python 3.9 is dropped, they should be annotated
# using ``typing.TypeAlias`` and Unions should be converted to using ``|`` syntax.
RGBColorType = Union[tuple[float, float, float], str]
RGBAColorType = Union[
str, # "none" or "#RRGGBBAA"/"#RGBA" hex strings
tuple[float, float, float, float],
# 2 tuple (color, alpha) representations, not infinitely recursive
# RGBColorType includes the (str, float) tuple, even for RGBA strings
tuple[RGBColorType, float],
# (4-tuple, float) is odd, but accepted as the outer float overriding A of 4-tuple
tuple[tuple[float, float, float, float], float],
]
ColorType = Union[RGBColorType, RGBAColorType]
RGBColourType = RGBColorType
RGBAColourType = RGBAColorType
ColourType = ColorType
LineStyleType = Union[str, tuple[float, Sequence[float]]]
DrawStyleType = Literal["default", "steps", "steps-pre", "steps-mid", "steps-post"]
MarkEveryType = Union[
None, int, tuple[int, int], slice, list[int], float, tuple[float, float], list[bool]
]
MarkerType = Union[str, path.Path, MarkerStyle]
FillStyleType = Literal["full", "left", "right", "bottom", "top", "none"]
JoinStyleType = Union[JoinStyle, Literal["miter", "round", "bevel"]]
CapStyleType = Union[CapStyle, Literal["butt", "projecting", "round"]]
RcStyleType = Union[
str,
dict[str, Any],
pathlib.Path,
Sequence[Union[str, pathlib.Path, dict[str, Any]]],
]
_HT = TypeVar("_HT", bound=Hashable)
HashableList = list[Union[_HT, "HashableList[_HT]"]]
"""A nested list of Hashable values."""