From d1765c315fb5dd308663fa2a5d1b371597131ee1 Mon Sep 17 00:00:00 2001 From: Boger Date: Mon, 28 Oct 2019 22:30:19 +0300 Subject: [PATCH 1/4] Add sort_keys param to all dump-like functions in PyYAML (yaml) lib --- third_party/2and3/yaml/__init__.pyi | 16 ++++++++-------- third_party/2and3/yaml/dumper.pyi | 6 +++--- third_party/2and3/yaml/representer.pyi | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/third_party/2and3/yaml/__init__.pyi b/third_party/2and3/yaml/__init__.pyi index 8af0d23ff4c5..8588cb6d7a3c 100644 --- a/third_party/2and3/yaml/__init__.pyi +++ b/third_party/2and3/yaml/__init__.pyi @@ -42,24 +42,24 @@ def serialize(node, stream: IO[str], Dumper=..., canonical=..., indent=..., widt def serialize(node, stream: None = ..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=...) -> _Yaml: ... @overload -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: ... +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=..., sort_keys=...) -> None: ... @overload -def dump_all(documents: Sequence[Any], stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=...) -> _Yaml: ... +def dump_all(documents: Sequence[Any], stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... @overload -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: ... +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=..., sort_keys=...) -> None: ... @overload -def dump(data: Any, stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=...) -> _Yaml: ... +def dump(data: Any, stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... @overload -def safe_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: ... +def safe_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=..., sort_keys=...) -> None: ... @overload -def safe_dump_all(documents: Sequence[Any], stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=...) -> _Yaml: ... +def safe_dump_all(documents: Sequence[Any], stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... @overload -def safe_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: ... +def safe_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=..., sort_keys=...) -> None: ... @overload -def safe_dump(data: Any, stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=...) -> _Yaml: ... +def safe_dump(data: Any, stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... def add_implicit_resolver(tag, regexp, first=..., Loader=..., Dumper=...): ... def add_path_resolver(tag, path, kind=..., Loader=..., Dumper=...): ... diff --git a/third_party/2and3/yaml/dumper.pyi b/third_party/2and3/yaml/dumper.pyi index 0586f1313ef1..658bfee8e1d8 100644 --- a/third_party/2and3/yaml/dumper.pyi +++ b/third_party/2and3/yaml/dumper.pyi @@ -4,10 +4,10 @@ from yaml.representer import BaseRepresenter, Representer, SafeRepresenter from yaml.resolver import BaseResolver, Resolver class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): - def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> None: ... class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): - def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> None: ... class Dumper(Emitter, Serializer, Representer, Resolver): - def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> None: ... diff --git a/third_party/2and3/yaml/representer.pyi b/third_party/2and3/yaml/representer.pyi index 7d4bbcc06bfe..b49049f00783 100644 --- a/third_party/2and3/yaml/representer.pyi +++ b/third_party/2and3/yaml/representer.pyi @@ -8,10 +8,11 @@ class BaseRepresenter: yaml_multi_representers: Any default_style: Any default_flow_style: Any + sort_keys: bool represented_objects: Any object_keeper: Any alias_key: Any - def __init__(self, default_style=..., default_flow_style=...) -> None: ... + def __init__(self, default_style=..., default_flow_style=..., sort_keys=...) -> None: ... def represent(self, data): ... def get_classobj_bases(self, cls): ... def represent_data(self, data): ... From 03abc3aa3c43c7125045cff4c32f2c151d326b52 Mon Sep 17 00:00:00 2001 From: Boger Date: Mon, 28 Oct 2019 22:38:38 +0300 Subject: [PATCH 2/4] Change `bool` to `Any` for sort_keys in Representer --- third_party/2and3/yaml/representer.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/2and3/yaml/representer.pyi b/third_party/2and3/yaml/representer.pyi index b49049f00783..fd5f84ca937a 100644 --- a/third_party/2and3/yaml/representer.pyi +++ b/third_party/2and3/yaml/representer.pyi @@ -8,7 +8,7 @@ class BaseRepresenter: yaml_multi_representers: Any default_style: Any default_flow_style: Any - sort_keys: bool + sort_keys: Any represented_objects: Any object_keeper: Any alias_key: Any From cd1e3d2ea31ee9c2a0258f36ec51e56945691bdc Mon Sep 17 00:00:00 2001 From: Boger Date: Mon, 28 Oct 2019 23:05:46 +0300 Subject: [PATCH 3/4] Change `Any` to stricter typing `bool` for sort_keys --- third_party/2and3/yaml/__init__.pyi | 16 ++++++++-------- third_party/2and3/yaml/dumper.pyi | 6 +++--- third_party/2and3/yaml/representer.pyi | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/third_party/2and3/yaml/__init__.pyi b/third_party/2and3/yaml/__init__.pyi index 8588cb6d7a3c..4a221883d24a 100644 --- a/third_party/2and3/yaml/__init__.pyi +++ b/third_party/2and3/yaml/__init__.pyi @@ -42,24 +42,24 @@ def serialize(node, stream: IO[str], Dumper=..., canonical=..., indent=..., widt def serialize(node, stream: None = ..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=...) -> _Yaml: ... @overload -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=..., sort_keys=...) -> None: ... +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=..., sort_keys: bool = ...) -> None: ... @overload -def dump_all(documents: Sequence[Any], stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... +def dump_all(documents: Sequence[Any], stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> _Yaml: ... @overload -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=..., sort_keys=...) -> None: ... +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=..., sort_keys: bool = ...) -> None: ... @overload -def dump(data: Any, stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... +def dump(data: Any, stream: None = ..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> _Yaml: ... @overload -def safe_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=..., sort_keys=...) -> None: ... +def safe_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=..., sort_keys: bool = ...) -> None: ... @overload -def safe_dump_all(documents: Sequence[Any], stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... +def safe_dump_all(documents: Sequence[Any], stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> _Yaml: ... @overload -def safe_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=..., sort_keys=...) -> None: ... +def safe_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=..., sort_keys: bool = ...) -> None: ... @overload -def safe_dump(data: Any, stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> _Yaml: ... +def safe_dump(data: Any, stream: None = ..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding: Optional[_Str] = ..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> _Yaml: ... def add_implicit_resolver(tag, regexp, first=..., Loader=..., Dumper=...): ... def add_path_resolver(tag, path, kind=..., Loader=..., Dumper=...): ... diff --git a/third_party/2and3/yaml/dumper.pyi b/third_party/2and3/yaml/dumper.pyi index 658bfee8e1d8..e2613ef5b325 100644 --- a/third_party/2and3/yaml/dumper.pyi +++ b/third_party/2and3/yaml/dumper.pyi @@ -4,10 +4,10 @@ from yaml.representer import BaseRepresenter, Representer, SafeRepresenter from yaml.resolver import BaseResolver, Resolver class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): - def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> None: ... + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> None: ... class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): - def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> None: ... + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> None: ... class Dumper(Emitter, Serializer, Representer, Resolver): - def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys=...) -> None: ... + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=..., sort_keys: bool = ...) -> None: ... diff --git a/third_party/2and3/yaml/representer.pyi b/third_party/2and3/yaml/representer.pyi index fd5f84ca937a..7b6757101685 100644 --- a/third_party/2and3/yaml/representer.pyi +++ b/third_party/2and3/yaml/representer.pyi @@ -8,11 +8,11 @@ class BaseRepresenter: yaml_multi_representers: Any default_style: Any default_flow_style: Any - sort_keys: Any + sort_keys: bool represented_objects: Any object_keeper: Any alias_key: Any - def __init__(self, default_style=..., default_flow_style=..., sort_keys=...) -> None: ... + def __init__(self, default_style=..., default_flow_style=..., sort_keys: bool =...) -> None: ... def represent(self, data): ... def get_classobj_bases(self, cls): ... def represent_data(self, data): ... From f7b428037239ce5c5d9068c4325d4d56fee9a37d Mon Sep 17 00:00:00 2001 From: Boger Date: Mon, 28 Oct 2019 23:09:31 +0300 Subject: [PATCH 4/4] Fix code style issue with missed space :sad_pepe: --- third_party/2and3/yaml/representer.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/2and3/yaml/representer.pyi b/third_party/2and3/yaml/representer.pyi index 7b6757101685..eca81cf15857 100644 --- a/third_party/2and3/yaml/representer.pyi +++ b/third_party/2and3/yaml/representer.pyi @@ -12,7 +12,7 @@ class BaseRepresenter: represented_objects: Any object_keeper: Any alias_key: Any - def __init__(self, default_style=..., default_flow_style=..., sort_keys: bool =...) -> None: ... + def __init__(self, default_style=..., default_flow_style=..., sort_keys: bool = ...) -> None: ... def represent(self, data): ... def get_classobj_bases(self, cls): ... def represent_data(self, data): ...