|
| 1 | +import datetime |
1 | 2 | import sys
|
2 |
| -from typing import Any |
| 3 | +from types import BuiltinFunctionType, FunctionType, ModuleType |
| 4 | +from typing import Any, Callable, ClassVar, Mapping, NoReturn, Sequence, Tuple, Type, TypeVar |
3 | 5 |
|
4 |
| -from yaml.error import YAMLError |
| 6 | +from yaml.error import YAMLError as YAMLError |
| 7 | +from yaml.nodes import MappingNode as MappingNode, Node as Node, ScalarNode as ScalarNode, SequenceNode as SequenceNode |
| 8 | + |
| 9 | +_T = TypeVar("_T") |
| 10 | +_R = TypeVar("_R", bound=BaseRepresenter) |
5 | 11 |
|
6 | 12 | class RepresenterError(YAMLError): ...
|
7 | 13 |
|
8 | 14 | class BaseRepresenter:
|
9 |
| - yaml_representers: Any |
10 |
| - yaml_multi_representers: Any |
11 |
| - default_style: Any |
12 |
| - default_flow_style: Any |
| 15 | + yaml_representers: ClassVar[dict[Type[Any], Callable[[BaseRepresenter, Any], Node]]] |
| 16 | + yaml_multi_representers: ClassVar[dict[Type[Any], Callable[[BaseRepresenter, Any], Node]]] |
| 17 | + default_style: str | Any |
13 | 18 | sort_keys: bool
|
14 |
| - represented_objects: Any |
15 |
| - object_keeper: Any |
16 |
| - alias_key: Any |
17 |
| - def __init__(self, default_style=..., default_flow_style=..., sort_keys: bool = ...) -> None: ... |
18 |
| - def represent(self, data): ... |
| 19 | + default_flow_style: bool |
| 20 | + represented_objects: dict[int, Node] |
| 21 | + object_keeper: list[Any] |
| 22 | + alias_key: int | Any |
| 23 | + def __init__(self, default_style: str | None = ..., default_flow_style: bool = ..., sort_keys: bool = ...) -> None: ... |
| 24 | + def represent(self, data) -> None: ... |
| 25 | + def represent_data(self, data) -> Node: ... |
19 | 26 | if sys.version_info < (3, 0):
|
20 | 27 | def get_classobj_bases(self, cls): ...
|
21 |
| - def represent_data(self, data): ... |
22 | 28 | @classmethod
|
23 |
| - def add_representer(cls, data_type, representer): ... |
| 29 | + def add_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... |
24 | 30 | @classmethod
|
25 |
| - def add_multi_representer(cls, data_type, representer): ... |
26 |
| - def represent_scalar(self, tag, value, style=...): ... |
27 |
| - def represent_sequence(self, tag, sequence, flow_style=...): ... |
28 |
| - def represent_mapping(self, tag, mapping, flow_style=...): ... |
29 |
| - def ignore_aliases(self, data): ... |
| 31 | + def add_multi_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... |
| 32 | + def represent_scalar(self, tag: str, value, style: str | None = ...) -> ScalarNode: ... |
| 33 | + def represent_sequence(self, tag: str, sequence: Sequence[Any], flow_style: bool | None = ...) -> SequenceNode: ... |
| 34 | + def represent_mapping(self, tag: str, mapping: Mapping[Any, Any], flow_style: bool | None = ...) -> MappingNode: ... |
| 35 | + def ignore_aliases(self, data) -> bool: ... |
30 | 36 |
|
31 | 37 | class SafeRepresenter(BaseRepresenter):
|
32 |
| - def ignore_aliases(self, data): ... |
33 |
| - def represent_none(self, data): ... |
34 |
| - def represent_str(self, data): ... |
| 38 | + inf_value: ClassVar[float] |
| 39 | + def ignore_aliases(self, data) -> bool: ... |
| 40 | + def represent_none(self, data) -> ScalarNode: ... |
| 41 | + def represent_str(self, data: str) -> ScalarNode: ... |
35 | 42 | if sys.version_info < (3, 0):
|
36 | 43 | def represent_unicode(self, data): ...
|
37 | 44 | def represent_long(self, data): ...
|
38 |
| - def represent_bool(self, data): ... |
39 |
| - def represent_int(self, data): ... |
40 |
| - inf_value: Any |
41 |
| - def represent_float(self, data): ... |
42 |
| - def represent_list(self, data): ... |
43 |
| - def represent_dict(self, data): ... |
44 |
| - def represent_set(self, data): ... |
45 |
| - def represent_date(self, data): ... |
46 |
| - def represent_datetime(self, data): ... |
47 |
| - def represent_yaml_object(self, tag, data, cls, flow_style=...): ... |
48 |
| - def represent_undefined(self, data): ... |
| 45 | + def represent_binary(self, data: bytes) -> ScalarNode: ... |
| 46 | + def represent_bool(self, data: bool) -> ScalarNode: ... |
| 47 | + def represent_int(self, data: int) -> ScalarNode: ... |
| 48 | + def represent_float(self, data: float) -> ScalarNode: ... |
| 49 | + def represent_list(self, data: Sequence[Any]) -> SequenceNode: ... |
| 50 | + def represent_dict(self, data: Mapping[Any, Any]) -> MappingNode: ... |
| 51 | + def represent_set(self, data: set[Any]) -> MappingNode: ... |
| 52 | + def represent_date(self, data: datetime.date) -> ScalarNode: ... |
| 53 | + def represent_datetime(self, data: datetime.datetime) -> ScalarNode: ... |
| 54 | + def represent_yaml_object(self, tag: str, data, cls, flow_style: bool | None = ...) -> MappingNode: ... |
| 55 | + def represent_undefined(self, data) -> NoReturn: ... |
49 | 56 |
|
50 | 57 | class Representer(SafeRepresenter):
|
51 |
| - def represent_str(self, data): ... |
52 | 58 | if sys.version_info < (3, 0):
|
53 | 59 | def represent_unicode(self, data): ...
|
54 | 60 | def represent_long(self, data): ...
|
55 | 61 | def represent_instance(self, data): ...
|
56 |
| - def represent_complex(self, data): ... |
57 |
| - def represent_tuple(self, data): ... |
58 |
| - def represent_name(self, data): ... |
59 |
| - def represent_module(self, data): ... |
60 |
| - def represent_object(self, data): ... |
| 62 | + def represent_complex(self, data: complex) -> ScalarNode: ... |
| 63 | + def represent_tuple(self, data: Tuple[Any, ...]) -> SequenceNode: ... |
| 64 | + def represent_name(self, data: BuiltinFunctionType | FunctionType) -> ScalarNode: ... |
| 65 | + def represent_module(self, data: ModuleType) -> ScalarNode: ... |
| 66 | + def represent_object(self, data) -> SequenceNode | MappingNode: ... |
| 67 | + def represent_ordered_dict(self, data: Mapping[Any, Any]) -> SequenceNode: ... |
0 commit comments