add type hints for yaml.add_constructor and construct_scalar (#4796)

This commit is contained in:
MrGreenTea
2021-01-23 20:46:51 +01:00
committed by GitHub
parent e713c2fff4
commit 462005b77d
2 changed files with 9 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import sys
from typing import IO, Any, Iterator, Optional, Sequence, Text, Union, overload
from typing import IO, Any, Callable, Iterator, Optional, Sequence, Text, Union, overload
from yaml.dumper import * # noqa: F403
from yaml.error import * # noqa: F403
@@ -256,7 +256,7 @@ def safe_dump(
) -> _Yaml: ...
def add_implicit_resolver(tag, regexp, first=..., Loader=..., Dumper=...): ...
def add_path_resolver(tag, path, kind=..., Loader=..., Dumper=...): ...
def add_constructor(tag, constructor, Loader=...): ...
def add_constructor(tag: _Str, constructor: Callable[[Loader, Node], Any], Loader: Loader = ...): ...
def add_multi_constructor(tag_prefix, multi_constructor, Loader=...): ...
def add_representer(data_type, representer, Dumper=...): ...
def add_multi_representer(data_type, multi_representer, Dumper=...): ...

View File

@@ -1,7 +1,10 @@
import sys
from typing import Any
from typing import Any, Text, Union
from yaml.error import MarkedYAMLError
from yaml.nodes import ScalarNode
_Scalar = Union[Text, int, float, bool, None]
class ConstructorError(MarkedYAMLError): ...
@@ -15,10 +18,10 @@ class BaseConstructor:
def __init__(self) -> None: ...
def check_data(self): ...
def get_data(self): ...
def get_single_data(self): ...
def get_single_data(self) -> Any: ...
def construct_document(self, node): ...
def construct_object(self, node, deep=...): ...
def construct_scalar(self, node): ...
def construct_scalar(self, node: ScalarNode) -> _Scalar: ...
def construct_sequence(self, node, deep=...): ...
def construct_mapping(self, node, deep=...): ...
def construct_pairs(self, node, deep=...): ...
@@ -28,7 +31,7 @@ class BaseConstructor:
def add_multi_constructor(cls, tag_prefix, multi_constructor): ...
class SafeConstructor(BaseConstructor):
def construct_scalar(self, node): ...
def construct_scalar(self, node: ScalarNode) -> _Scalar: ...
def flatten_mapping(self, node): ...
def construct_mapping(self, node, deep=...): ...
def construct_yaml_null(self, node): ...