Skip to content

Commit b887713

Browse files
committed
Fix yaml overload
Depending on if a "stream" or the "encoding" is given, the functions either return None, str/unicode or bytes. Use @overload fix distinguish those cases. Also fix the functions using **kwds as they delegate their work to the more generic functions: copy their signatures.
1 parent f5e4f7f commit b887713

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

third_party/2and3/yaml/__init__.pyi

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,46 @@ def safe_load_all(stream: Union[str, IO[str]]) -> Iterator[Any]: ...
2222
def emit(events, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=...): ...
2323

2424
@overload
25-
def serialize_all(nodes, stream: None=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> AnyStr: ...
25+
def serialize_all(nodes, stream: None=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: None=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> str: ...
26+
@overload
27+
def serialize_all(nodes, stream: None=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: str=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> bytes: ...
2628
@overload
2729
def serialize_all(nodes, stream: IO[str], Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ...
2830

29-
def serialize(node, stream=..., Dumper=..., **kwds): ...
31+
@overload
32+
def serialize(node, stream: None=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: None=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> str: ...
33+
@overload
34+
def serialize(node, stream: None=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: str=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> bytes: ...
35+
@overload
36+
def serialize(node, stream: IO[str], Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ...
3037

3138
@overload
32-
def dump_all(documents: Sequence[Any], stream: None=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> AnyStr: ...
39+
def dump_all(documents: Sequence[Any], stream: None=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: None=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> str: ...
40+
@overload
41+
def dump_all(documents: Sequence[Any], stream: None=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: str=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> bytes: ...
3342
@overload
3443
def dump_all(documents: Sequence[Any], stream: IO[str], Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ...
3544

3645
@overload
37-
def dump(data: Any, stream: None=..., Dumper=..., **kwds) -> AnyStr: ...
46+
def dump(data: Any, stream: None=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: None=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> str: ...
47+
@overload
48+
def dump(data: Any, stream: None=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: str=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> bytes: ...
3849
@overload
39-
def dump(data: Any, stream: IO[str], Dumper=..., **kwds) -> None: ...
50+
def dump(data: Any, stream: IO[str], Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ...
4051

4152
@overload
42-
def safe_dump_all(documents: Sequence[Any], stream: None=..., **kwds) -> AnyStr: ...
53+
def save_dump_all(documents: Sequence[Any], stream: None=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: None=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> str: ...
4354
@overload
44-
def safe_dump_all(documents: Sequence[Any], stream: IO[str], **kwds) -> None: ...
55+
def save_dump_all(documents: Sequence[Any], stream: None=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: str=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> bytes: ...
56+
@overload
57+
def save_dump_all(documents: Sequence[Any], stream: IO[str], default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ...
4558

4659
@overload
47-
def safe_dump(data: Any, stream: None=..., **kwds) -> AnyStr: ...
60+
def save_dump(data: Any, stream: None=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: None=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> str: ...
61+
@overload
62+
def save_dump(data: Any, stream: None=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: str=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> bytes: ...
4863
@overload
49-
def safe_dump(data: Any, stream: IO[str], **kwds) -> None: ...
64+
def save_dump(data: Any, stream: IO[str], default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ...
5065

5166
def add_implicit_resolver(tag, regexp, first=..., Loader=..., Dumper=...): ...
5267
def add_path_resolver(tag, path, kind=..., Loader=..., Dumper=...): ...

0 commit comments

Comments
 (0)