|
11 | 11 | ValuesView) |
12 | 12 | from io import open |
13 | 13 | from pprint import pformat as pretty |
14 | | -# TODO: py3.10: typing.Optional, typing.Union -> '|' operator |
15 | | -from typing import Any, Optional, Union |
| 14 | +from typing import TYPE_CHECKING |
16 | 15 |
|
17 | | -from _typeshed import StrPath |
| 16 | +if TYPE_CHECKING: |
| 17 | + # TODO: py3.10: typing.Optional, typing.Union -> '|' operator |
| 18 | + from typing import Any, Optional, Union |
18 | 19 |
|
19 | | -if sys.version_info >= (3, 10): |
20 | | - from typing import Self, TypeAlias |
21 | | -else: |
22 | | - from typing_extensions import TypeAlias, Self |
| 20 | + from _typeshed import StrPath |
| 21 | + |
| 22 | + if sys.version_info >= (3, 10): |
| 23 | + from typing import Self, TypeAlias |
| 24 | + else: |
| 25 | + from typing_extensions import TypeAlias, Self |
23 | 26 |
|
24 | 27 | import jsonschema |
25 | 28 | from ruamel.yaml import YAML |
|
38 | 41 | MAIN = "main" + SUFFIX |
39 | 42 | IGNORED_DIRECTORIES = ['/dev', '/proc', '/sys'] |
40 | 43 |
|
41 | | -# TypeHints |
42 | | -RawDataType: TypeAlias = Union[None, int, float, str, bool] |
43 | | -ListDataType: TypeAlias = list[Union[RawDataType, 'ListDataType', 'DictDataType']] |
44 | | -DictDataType: TypeAlias = dict[str, Union[RawDataType, ListDataType, 'DictDataType']] |
45 | | -# Equivalent to: |
46 | | -# JSON: TypeAlias = dict[str, "JSON"] | list["JSON"] | str | int | float | bool | None |
47 | | -DataType: TypeAlias = Union[RawDataType, ListDataType, DictDataType] |
48 | | -TreeData: TypeAlias = dict[str, DataType] |
49 | | -TreeDataPath: TypeAlias = Union[TreeData, str] # Either TreeData or path |
50 | | -JsonSchema: TypeAlias = Mapping[str, Any] |
| 44 | +if TYPE_CHECKING: |
| 45 | + # TypeHints |
| 46 | + RawDataType: TypeAlias = Union[None, int, float, str, bool] |
| 47 | + ListDataType: TypeAlias = list[Union[RawDataType, 'ListDataType', 'DictDataType']] |
| 48 | + DictDataType: TypeAlias = dict[str, Union[RawDataType, ListDataType, 'DictDataType']] |
| 49 | + # Equivalent to: |
| 50 | + # JSON: TypeAlias = dict[str, "JSON"] | list["JSON"] | str | int | float | bool | None |
| 51 | + DataType: TypeAlias = Union[RawDataType, ListDataType, DictDataType] |
| 52 | + TreeData: TypeAlias = dict[str, DataType] |
| 53 | + TreeDataPath: TypeAlias = Union[TreeData, str] # Either TreeData or path |
| 54 | + JsonSchema: TypeAlias = Mapping[str, Any] |
51 | 55 |
|
52 | 56 |
|
53 | 57 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
0 commit comments