diff --git a/third_party/2and3/yaml/__init__.pyi b/third_party/2and3/yaml/__init__.pyi index ac8dd0274..50802e428 100644 --- a/third_party/2and3/yaml/__init__.pyi +++ b/third_party/2and3/yaml/__init__.pyi @@ -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=...): ... diff --git a/third_party/2and3/yaml/constructor.pyi b/third_party/2and3/yaml/constructor.pyi index 8ea89c615..f1aeeee19 100644 --- a/third_party/2and3/yaml/constructor.pyi +++ b/third_party/2and3/yaml/constructor.pyi @@ -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): ...