Add a couple of missing type hints in pyyaml.constructor (#8965)

This commit is contained in:
Anton Grübel
2022-10-26 09:15:35 +02:00
committed by GitHub
parent 7ba0479d75
commit 84682a1d54

View File

@@ -1,11 +1,12 @@
from collections.abc import Callable
from collections.abc import Callable, Hashable
from datetime import date
from re import Pattern
from typing import Any, TypeVar
from typing import Any, ClassVar, TypeVar
from typing_extensions import TypeAlias
from yaml.error import MarkedYAMLError
from yaml.loader import BaseLoader, FullLoader, Loader, SafeLoader, UnsafeLoader
from yaml.nodes import Node, ScalarNode
from yaml.nodes import MappingNode, Node, ScalarNode, SequenceNode
_L = TypeVar("_L", bound=Loader | BaseLoader | FullLoader | SafeLoader | UnsafeLoader)
_N = TypeVar("_N", bound=Node)
@@ -29,8 +30,8 @@ class BaseConstructor:
def construct_document(self, node): ...
def construct_object(self, node, deep=...): ...
def construct_scalar(self, node: ScalarNode) -> _Scalar: ...
def construct_sequence(self, node, deep=...): ...
def construct_mapping(self, node, deep=...): ...
def construct_sequence(self, node: SequenceNode, deep: bool = ...) -> list[Any]: ...
def construct_mapping(self, node: MappingNode, deep: bool = ...) -> dict[Hashable, Any]: ...
def construct_pairs(self, node, deep=...): ...
@classmethod
# Use typevars so we can have covariant behaviour in the parameter types
@@ -40,18 +41,18 @@ class BaseConstructor:
class SafeConstructor(BaseConstructor):
def construct_scalar(self, node: ScalarNode) -> _Scalar: ...
def flatten_mapping(self, node): ...
def construct_mapping(self, node, deep=...): ...
def construct_yaml_null(self, node): ...
bool_values: Any
def construct_yaml_bool(self, node): ...
def construct_yaml_int(self, node): ...
inf_value: Any
nan_value: Any
def construct_yaml_float(self, node): ...
def construct_yaml_binary(self, node): ...
timestamp_regexp: Any
def construct_yaml_timestamp(self, node): ...
def flatten_mapping(self, node: MappingNode) -> None: ...
def construct_mapping(self, node: MappingNode, deep: bool = ...) -> dict[Hashable, Any]: ...
def construct_yaml_null(self, node: ScalarNode) -> None: ...
bool_values: ClassVar[dict[str, bool]]
def construct_yaml_bool(self, node: ScalarNode) -> bool: ...
def construct_yaml_int(self, node: ScalarNode) -> int: ...
inf_value: ClassVar[float]
nan_value: ClassVar[float]
def construct_yaml_float(self, node: ScalarNode) -> float: ...
def construct_yaml_binary(self, node: ScalarNode) -> bytes: ...
timestamp_regexp: ClassVar[Pattern[str]]
def construct_yaml_timestamp(self, node: ScalarNode) -> date: ...
def construct_yaml_omap(self, node): ...
def construct_yaml_pairs(self, node): ...
def construct_yaml_set(self, node): ...