diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-12 14:53:57 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-12 14:53:57 +0200 |
commit | bf94f1d0fe36687a09beb7a4d48564127b9d157e (patch) | |
tree | 1945392e75b15985dbd68b80590388905be7effe /comments.py | |
parent | 9df115f3280e32fc4a64cafb3645af9574ff9f96 (diff) | |
download | ruamel.yaml-bf94f1d0fe36687a09beb7a4d48564127b9d157e.tar.gz |
get rid of mypy error not MRO-ing subclass MutableSet + MutableMap
Diffstat (limited to 'comments.py')
-rw-r--r-- | comments.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/comments.py b/comments.py index fd28a62..ff0080f 100644 --- a/comments.py +++ b/comments.py @@ -656,7 +656,7 @@ class CommentedMap(CommentedBase, MutableMapping): self.ca.comment[1] = pre_comments return pre_comments - def update(self, vals): + def update(self, vals): # type: ignore # type: (Any) -> None try: self._od.update(vals) @@ -947,7 +947,7 @@ class CommentedOrderedMap(CommentedMap): __slots__ = (Comment.attrib,) -class CommentedSet(MutableSet, CommentedMap): # NOQA +class CommentedSet(MutableSet, CommentedBase): # NOQA __slots__ = Comment.attrib, 'odict' def __init__(self, values=None): @@ -957,6 +957,22 @@ class CommentedSet(MutableSet, CommentedMap): # NOQA if values is not None: self |= values # type: ignore + def _yaml_add_comment(self, comment, key=NoComment, value=NoComment): + # type: (Any, Optional[Any], Optional[Any]) -> None + """values is set to key to indicate a value attachment of comment""" + if key is not NoComment: + self.yaml_key_comment_extend(key, comment) + return + if value is not NoComment: + self.yaml_value_comment_extend(value, comment) + else: + self.ca.comment = comment + + def _yaml_add_eol_comment(self, comment, key): + # type: (Any, Any) -> None + """add on the value line, with value specified by the key""" + self._yaml_add_comment(comment, value=key) + def add(self, value): # type: (Any) -> None """Add an element.""" |