summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-01-22 11:35:48 +0100
committerAnthon van der Neut <anthon@mnt.org>2017-01-22 11:35:48 +0100
commitc86bc3f31f6baee3db7d719455f94712ec375e79 (patch)
tree0beb7bdcef755ee72aeae78a5387980704174f42
parent73615a8f615632ce877066420d9b6e6b45a480f4 (diff)
downloadruamel.yaml-c86bc3f31f6baee3db7d719455f94712ec375e79.tar.gz
fix #93: extra empty line inserted on roundtrip0.13.10
This happened only on comments between indented sequence elements
-rw-r--r--README.rst4
-rw-r--r--__init__.py2
-rw-r--r--_test/test_comments.py32
-rw-r--r--emitter.py1
-rw-r--r--setup.py7
5 files changed, 43 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 8fc7fd9..4ac5d5c 100644
--- a/README.rst
+++ b/README.rst
@@ -18,6 +18,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key
+0.13.10 (2017-01-22):
+ - fix for issue 93, insert spurious blank line before single line comment
+ between indented sequence elements (reported by Alex)
+
0.13.9 (2017-01-18):
- fix for issue 92, wrong import name reported by the-corinthian
diff --git a/__init__.py b/__init__.py
index 6c0bb60..40e77b5 100644
--- a/__init__.py
+++ b/__init__.py
@@ -9,7 +9,7 @@ from __future__ import absolute_import
_package_data = dict(
full_package_name="ruamel.yaml",
- version_info=(0, 13, 9),
+ version_info=(0, 13, 10),
author="Anthon van der Neut",
author_email="a.van.der.neut@ruamel.eu",
description="ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order", # NOQA
diff --git a/_test/test_comments.py b/_test/test_comments.py
index 019d8b7..7673094 100644
--- a/_test/test_comments.py
+++ b/_test/test_comments.py
@@ -638,6 +638,38 @@ class TestEmptyLines:
y = round_trip_dump(d, indent=4)
assert yaml_str == y
+ def test_issue_93(self):
+ round_trip("""\
+ a:
+ b:
+ - c1: cat # a1
+ # my comment on catfish
+ - c2: catfish # a2
+ """)
+
+ def test_issue_93_00(self):
+ round_trip("""\
+ a:
+ - - c1: cat # a1
+ # my comment on catfish
+ - c2: catfish # a2
+ """)
+
+ def test_issue_93_01(self):
+ round_trip("""\
+ - - c1: cat # a1
+ # my comment on catfish
+ - c2: catfish # a2
+ """)
+
+ def test_issue_93_02(self):
+ # never failed as there is no indent
+ round_trip("""\
+ - c1: cat
+ # my comment on catfish
+ - c2: catfish
+ """)
+
class TestUnicodeComments:
@pytest.mark.skipif(ruamel.yaml.reader.Reader.UNICODE_SIZE < 4,
diff --git a/emitter.py b/emitter.py
index 51ce3ac..21961b3 100644
--- a/emitter.py
+++ b/emitter.py
@@ -434,7 +434,6 @@ class Emitter(object):
self.indent = self.indents.pop()
self.state = self.states.pop()
else:
- self.write_indent()
if self.event.comment and self.event.comment[1]:
self.write_pre_comment(self.event)
self.write_indent()
diff --git a/setup.py b/setup.py
index 495d08a..eafeb1f 100644
--- a/setup.py
+++ b/setup.py
@@ -586,6 +586,11 @@ class NameSpacePackager(object):
to be installed explicitly as they are not on PyPI
install_requires should be dict, with keys 'any', 'py27' etc
or a list (which is as if only 'any' was defined
+
+ ToDo: update with: pep508 conditional dependencies
+ https://www.python.org/dev/peps/pep-0508/
+ https://wheel.readthedocs.io/en/latest/index.html#defining-conditional-dependencies
+ https://hynek.me/articles/conditional-python-dependencies/
"""
if self._pkg[0] is None:
self._pkg[0] = []
@@ -683,7 +688,7 @@ class NameSpacePackager(object):
sources=[self.pn(x) for x in target['src']],
libraries=[self.pn(x) for x in target.get('lib')],
)
- self._ext_modules.append(ext)
+ self._ext_modules.append(ext)
return self._ext_modules
print('sys.argv', sys.argv)