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