diff options
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | README.rst | 8 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/_static/pypi.svg | 2 | ||||
-rw-r--r-- | _test/test_issues.py | 10 | ||||
-rw-r--r-- | _test/test_z_data.py | 4 | ||||
-rw-r--r-- | comments.py | 7 |
7 files changed, 35 insertions, 8 deletions
@@ -1,3 +1,11 @@ +[0, 15, 90]: 2019-04-04 + - fix issue with updating `CommentedMap` from list of tuples (reported by + `Peter Henry <https://bitbucket.org/mosbasik/>`__) + +[0, 15, 90]: 2019-04-04 + - fix issue with updating `CommentedMap` from list of tuples (reported by + `Peter Henry <https://bitbucket.org/mosbasik/>`__) + [0, 15, 89]: 2019-02-27 - fix for items with flow-mapping in block sequence output on single line (reported by `Zahari Dim <https://bitbucket.org/zahari_dim/>`__) @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.89 -:updated: 2019-02-27 +:version: 0.15.90 +:updated: 2019-04-04 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :pypi: https://pypi.org/project/ruamel.yaml/ @@ -54,6 +54,10 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) +0.15.90 (2019-04-04): + - fix issue with updating `CommentedMap` from list of tuples (reported by + `Peter Henry <https://bitbucket.org/mosbasik/>`__) + 0.15.89 (2019-02-27): - fix for items with flow-mapping in block sequence output on single line (reported by `Zahari Dim <https://bitbucket.org/zahari_dim/>`__) diff --git a/__init__.py b/__init__.py index c10c606..cb39f68 100644 --- a/__init__.py +++ b/__init__.py @@ -7,8 +7,8 @@ if False: # MYPY _package_data = dict( full_package_name='ruamel.yaml', - version_info=(0, 15, 89), - __version__='0.15.89', + version_info=(0, 15, 90), + __version__='0.15.90', 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/_doc/_static/pypi.svg b/_doc/_static/pypi.svg index c18afa1..eb22633 100644 --- a/_doc/_static/pypi.svg +++ b/_doc/_static/pypi.svg @@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.89</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.89</text></g> </svg> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.90</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.90</text></g> </svg> diff --git a/_test/test_issues.py b/_test/test_issues.py index 0d1a43d..5007f60 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -603,6 +603,16 @@ class TestIssues: with pytest.raises(RepresenterError, match='cannot represent'): yaml.dump({'t': t}, stdout) + def test_issue_282(self): + # update from list of tuples caused AttributeError + import ruamel.yaml + yaml_data = ruamel.yaml.comments.CommentedMap([('a', 'apple'), ('b', 'banana')]) + yaml_data.update([('c', 'cantaloupe')]) + yaml_data.update({'d': 'date', 'k': 'kiwi'}) + assert 'c' in yaml_data.keys() + assert 'c' in yaml_data._ok + + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): # inp = """ diff --git a/_test/test_z_data.py b/_test/test_z_data.py index f4e47cf..fcd09be 100644 --- a/_test/test_z_data.py +++ b/_test/test_z_data.py @@ -186,7 +186,7 @@ class TestYAMLData(object): data = doc else: print('no handler for type:', type(doc), repr(doc)) - assert False + raise AssertionError() if typ is None: if data is not None and output is not None: typ = 'rt' @@ -207,7 +207,7 @@ class TestYAMLData(object): self.load_assert(data, confirm, yaml_version=yaml_version) else: print('\nrun type unknown:', typ) - assert False + raise AssertionError() def check_python_version(match, current=None): diff --git a/comments.py b/comments.py index 2015cca..7f3f2d4 100644 --- a/comments.py +++ b/comments.py @@ -699,11 +699,16 @@ class CommentedMap(ordereddict, CommentedBase): # type: (Any) -> None try: ordereddict.update(self, vals) - self._ok.update(vals.keys()) # type: ignore except TypeError: # probably a dict that is used for x in vals: self[x] = vals[x] + try: + self._ok.update(vals.keys()) # type: ignore + except AttributeError: + # assume a list/tuple of two element lists/tuples + for x in vals: + self._ok.add(x[0]) def insert(self, pos, key, value, comment=None): # type: (Any, Any, Any, Optional[Any]) -> None |