diff --git a/stubs/PyYAML/yaml/representer.pyi b/stubs/PyYAML/yaml/representer.pyi index c6d1158ff..df4e9116f 100644 --- a/stubs/PyYAML/yaml/representer.pyi +++ b/stubs/PyYAML/yaml/representer.pyi @@ -1,7 +1,8 @@ import datetime import sys +from _typeshed import SupportsItems from types import BuiltinFunctionType, FunctionType, ModuleType -from typing import Any, Callable, ClassVar, Iterable, Mapping, NoReturn, Tuple, Type, TypeVar, Union +from typing import Any, Callable, ClassVar, Iterable, Mapping, NoReturn, Tuple, Type, TypeVar from yaml.error import YAMLError as YAMLError from yaml.nodes import MappingNode as MappingNode, Node as Node, ScalarNode as ScalarNode, SequenceNode as SequenceNode @@ -9,8 +10,6 @@ from yaml.nodes import MappingNode as MappingNode, Node as Node, ScalarNode as S _T = TypeVar("_T") _R = TypeVar("_R", bound=BaseRepresenter) -MappingLike = Union[Mapping[Any, Any], Iterable[Tuple[Any, Any]]] - class RepresenterError(YAMLError): ... class BaseRepresenter: @@ -33,7 +32,9 @@ class BaseRepresenter: def add_multi_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... def represent_scalar(self, tag: str, value, style: str | None = ...) -> ScalarNode: ... def represent_sequence(self, tag: str, sequence: Iterable[Any], flow_style: bool | None = ...) -> SequenceNode: ... - def represent_mapping(self, tag: str, mapping: MappingLike, flow_style: bool | None = ...) -> MappingNode: ... + def represent_mapping( + self, tag: str, mapping: SupportsItems[Any, Any] | Iterable[Tuple[Any, Any]], flow_style: bool | None = ... + ) -> MappingNode: ... def ignore_aliases(self, data) -> bool: ... class SafeRepresenter(BaseRepresenter): @@ -49,7 +50,7 @@ class SafeRepresenter(BaseRepresenter): def represent_int(self, data: int) -> ScalarNode: ... def represent_float(self, data: float) -> ScalarNode: ... def represent_list(self, data: Iterable[Any]) -> SequenceNode: ... - def represent_dict(self, data: MappingLike) -> MappingNode: ... + def represent_dict(self, data: SupportsItems[Any, Any] | Iterable[Tuple[Any, Any]]) -> MappingNode: ... def represent_set(self, data: Iterable[Any]) -> MappingNode: ... def represent_date(self, data: datetime.date) -> ScalarNode: ... def represent_datetime(self, data: datetime.datetime) -> ScalarNode: ...