summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-04-04 08:34:46 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-04-04 08:34:46 +0200
commit3d039055e72a8f3185089a2b9f1f162c6f453a77 (patch)
tree254a95bb590bd8b5174ad7b0f589c037073155e4
parent24bdc0073466057ba9288282f943205a32f3cdc8 (diff)
downloadruamel.yaml-0.15.90.tar.gz
fix update CommentedMap with list of tuples0.15.90
fixes issue #282 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
-rw-r--r--CHANGES8
-rw-r--r--README.rst8
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/test_issues.py10
-rw-r--r--_test/test_z_data.py4
-rw-r--r--comments.py7
7 files changed, 35 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index 3d283ef..9b46ce2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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/>`__)
diff --git a/README.rst b/README.rst
index 4b43bc5..54e3ba7 100644
--- a/README.rst
+++ b/README.rst
@@ -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