|
11 | 11 | """
|
12 | 12 | from collections.abc import Hashable, Sequence
|
13 | 13 | import pathlib
|
14 |
| -from typing import Any, Literal, TypeVar |
| 14 | +from typing import Any, Literal, TypeAlias, TypeVar |
15 | 15 |
|
16 | 16 | from . import path
|
17 | 17 | from ._enums import JoinStyle, CapStyle
|
18 | 18 | from .markers import MarkerStyle
|
19 | 19 |
|
20 |
| -# The following are type aliases. Once python 3.9 is dropped, they should be annotated |
21 |
| -# using ``typing.TypeAlias``. |
22 |
| - |
23 |
| -RGBColorType = tuple[float, float, float] | str |
24 |
| -RGBAColorType = ( |
| 20 | +RGBColorType: TypeAlias = tuple[float, float, float] | str |
| 21 | +RGBAColorType: TypeAlias = ( |
25 | 22 | str | # "none" or "#RRGGBBAA"/"#RGBA" hex strings
|
26 | 23 | tuple[float, float, float, float] |
|
27 | 24 | # 2 tuple (color, alpha) representations, not infinitely recursive
|
|
31 | 28 | tuple[tuple[float, float, float, float], float]
|
32 | 29 | )
|
33 | 30 |
|
34 |
| -ColorType = RGBColorType | RGBAColorType |
| 31 | +ColorType: TypeAlias = RGBColorType | RGBAColorType |
35 | 32 |
|
36 |
| -RGBColourType = RGBColorType |
37 |
| -RGBAColourType = RGBAColorType |
38 |
| -ColourType = ColorType |
| 33 | +RGBColourType: TypeAlias = RGBColorType |
| 34 | +RGBAColourType: TypeAlias = RGBAColorType |
| 35 | +ColourType: TypeAlias = ColorType |
39 | 36 |
|
40 |
| -LineStyleType = str | tuple[float, Sequence[float]] |
41 |
| -DrawStyleType = Literal["default", "steps", "steps-pre", "steps-mid", "steps-post"] |
42 |
| -MarkEveryType = ( |
| 37 | +LineStyleType: TypeAlias = str | tuple[float, Sequence[float]] |
| 38 | +DrawStyleType: TypeAlias = Literal["default", "steps", "steps-pre", "steps-mid", |
| 39 | + "steps-post"] |
| 40 | +MarkEveryType: TypeAlias = ( |
43 | 41 | None |
|
44 | 42 | int | tuple[int, int] | slice | list[int] |
|
45 | 43 | float | tuple[float, float] |
|
46 | 44 | list[bool]
|
47 | 45 | )
|
48 | 46 |
|
49 |
| -MarkerType = str | path.Path | MarkerStyle |
50 |
| -FillStyleType = Literal["full", "left", "right", "bottom", "top", "none"] |
51 |
| -JoinStyleType = JoinStyle | Literal["miter", "round", "bevel"] |
52 |
| -CapStyleType = CapStyle | Literal["butt", "projecting", "round"] |
| 47 | +MarkerType: TypeAlias = str | path.Path | MarkerStyle |
| 48 | +FillStyleType: TypeAlias = Literal["full", "left", "right", "bottom", "top", "none"] |
| 49 | +JoinStyleType: TypeAlias = JoinStyle | Literal["miter", "round", "bevel"] |
| 50 | +CapStyleType: TypeAlias = CapStyle | Literal["butt", "projecting", "round"] |
53 | 51 |
|
54 |
| -RcStyleType = ( |
| 52 | +RcStyleType: TypeAlias = ( |
55 | 53 | str |
|
56 | 54 | dict[str, Any] |
|
57 | 55 | pathlib.Path |
|
58 | 56 | Sequence[str | pathlib.Path | dict[str, Any]]
|
59 | 57 | )
|
60 | 58 |
|
61 | 59 | _HT = TypeVar("_HT", bound=Hashable)
|
62 |
| -HashableList = list[_HT | "HashableList[_HT]"] |
| 60 | +HashableList: TypeAlias = list[_HT | "HashableList[_HT]"] |
63 | 61 | """A nested list of Hashable values."""
|
0 commit comments