diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-07-15 20:22:24 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-07-15 20:22:24 +0200 |
commit | 0b9979e0dc182ef6ca966b5a6717740918348df4 (patch) | |
tree | ab4ac49ccee57f262a126fc457d03403f7b70761 /main.py | |
parent | 0efe181f5bdf6f961aa7658b4a0288af1b63213b (diff) | |
download | ruamel.yaml-0b9979e0dc182ef6ca966b5a6717740918348df4.tar.gz |
mypy update
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -455,6 +455,7 @@ class YAML(object): return res def register_class(self, cls): + # type:(Any) -> None """ register a class for dumping loading - if it has attribute yaml_tag use that to register, else use class name @@ -466,6 +467,7 @@ class YAML(object): self.representer.add_representer(cls, cls.to_yaml) except AttributeError: def t_y(representer, data): + # type: (Any, Any) -> Any return representer.represent_yaml_object( tag, data, cls, flow_style=representer.default_flow_style) @@ -474,12 +476,14 @@ class YAML(object): self.constructor.add_constructor(tag, cls.from_yaml) except AttributeError: def f_y(constructor, node): + # type: (Any, Any) -> Any return constructor.construct_yaml_object(node, cls) self.constructor.add_constructor(tag, f_y) def yaml_object(yml): + # type: (Any) -> Any """ decorator for classes that needs to dump/load objects The tag for such objects is taken from the class attribute yaml_tag (or the class name in lowercase in case unavailable) @@ -487,11 +491,13 @@ def yaml_object(yml): loading, default routines (dumping a mapping of the attributes) used otherwise. """ def yo_deco(cls): + # type: (Any) -> Any tag = getattr(cls, 'yaml_tag', '!' + cls.__name__) try: yml.representer.add_representer(cls, cls.to_yaml) except AttributeError: def t_y(representer, data): + # type: (Any, Any) -> Any return representer.represent_yaml_object( tag, data, cls, flow_style=representer.default_flow_style) @@ -500,6 +506,7 @@ def yaml_object(yml): yml.constructor.add_constructor(tag, cls.from_yaml) except AttributeError: def f_y(constructor, node): + # type: (Any, Any) -> Any return constructor.construct_yaml_object(node, cls) yml.constructor.add_constructor(tag, f_y) |