summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-07-15 20:22:24 +0200
committerAnthon van der Neut <anthon@mnt.org>2017-07-15 20:22:24 +0200
commit0b9979e0dc182ef6ca966b5a6717740918348df4 (patch)
treeab4ac49ccee57f262a126fc457d03403f7b70761 /main.py
parent0efe181f5bdf6f961aa7658b4a0288af1b63213b (diff)
downloadruamel.yaml-0b9979e0dc182ef6ca966b5a6717740918348df4.tar.gz
mypy update
Diffstat (limited to 'main.py')
-rw-r--r--main.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/main.py b/main.py
index c6779e2..58b1c81 100644
--- a/main.py
+++ b/main.py
@@ -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)