diff options
author | Anthon van der Neut <anthon@mnt.org> | 2021-03-20 06:12:56 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2021-03-20 06:12:56 +0100 |
commit | 1f3b14522756ad00c949d9c3a3d3587f48a67e7d (patch) | |
tree | e79f737326840a6cb7332d8a286fcf4e23219c34 | |
parent | e73562c6f14d1d71a9fea174d58465e1b13f68af (diff) | |
download | ruamel.yaml-1f3b14522756ad00c949d9c3a3d3587f48a67e7d.tar.gz |
remove superfluous comment assignment
-rw-r--r-- | constructor.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/constructor.py b/constructor.py index 7a84bd1..6c795c4 100644 --- a/constructor.py +++ b/constructor.py @@ -1286,6 +1286,8 @@ class RoundTripConstructor(SafeConstructor): if node.comment: seqtyp._yaml_add_comment(node.comment[:2]) if len(node.comment) > 2: + # this happens e.g. if you have a sequence element that is a flow-style mapping + # and that has no EOL comment but a following commentline or empty line seqtyp.yaml_end_comment_extend(node.comment[2], clear=True) if node.anchor: from ruamel.yaml.serializer import templated_id @@ -1294,7 +1296,7 @@ class RoundTripConstructor(SafeConstructor): seqtyp.yaml_set_anchor(node.anchor) for idx, child in enumerate(node.value): if child.comment: - seqtyp._yaml_add_comment(child.comment, key=idx) + seqtyp._yaml_add_comment(child.comment[:], key=idx) child.comment = None # if moved to sequence remove from child ret_val.append(self.construct_object(child, deep=deep)) seqtyp._yaml_set_idx_line_col( @@ -1521,8 +1523,8 @@ class RoundTripConstructor(SafeConstructor): # type: (Any) -> Any data = CommentedSeq() data._yaml_set_line_col(node.start_mark.line, node.start_mark.column) - if node.comment: - data._yaml_add_comment(node.comment) + # if node.comment: + # data._yaml_add_comment(node.comment) yield data data.extend(self.construct_rt_sequence(node, data)) self.set_collection_style(data, node) |