summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2020-09-22 08:29:17 +0200
committerAnthon van der Neut <anthon@mnt.org>2020-09-22 08:29:17 +0200
commitad245940e37c3169e990704c7b7a51813f48f8a8 (patch)
tree7c337dd1bcfb72389800bb344667e059d957f1aa
parent80e0a9cd0c1606a12cd0db59d1b137da531ce35e (diff)
downloadruamel.yaml-ad245940e37c3169e990704c7b7a51813f48f8a8.tar.gz
fix issue 359
-rw-r--r--README.rst4
-rw-r--r--comments.py16
2 files changed, 13 insertions, 7 deletions
diff --git a/README.rst b/README.rst
index f757911..b66d249 100644
--- a/README.rst
+++ b/README.rst
@@ -54,6 +54,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+NEXT:
+ - fix for issue 359: could not update() CommentedMap with keyword arguments
+ (reported by `Steve Franchak <https://sourceforge.net/u/binaryadder/>__)
+
0.16.12 (2020-09-04):
- update links in doc
diff --git a/comments.py b/comments.py
index 1cfd662..d00cf0d 100644
--- a/comments.py
+++ b/comments.py
@@ -696,20 +696,22 @@ class CommentedMap(ordereddict, CommentedBase): # type: ignore
self.ca.comment[1] = pre_comments
return pre_comments
- def update(self, vals):
- # type: (Any) -> None
+ def update(self, *vals, **kw):
+ # type: (Any, Any) -> None
try:
- ordereddict.update(self, vals)
+ ordereddict.update(self, *vals, **kw)
except TypeError:
# probably a dict that is used
- for x in vals:
- self[x] = vals[x]
+ for x in *vals:
+ self[x] = *vals[x]
try:
- self._ok.update(vals.keys()) # type: ignore
+ self._ok.update(*vals.keys()) # type: ignore
except AttributeError:
# assume a list/tuple of two element lists/tuples
- for x in vals:
+ for x in *vals:
self._ok.add(x[0])
+ if kw:
+ self._ok.add(*kw.keys())
def insert(self, pos, key, value, comment=None):
# type: (Any, Any, Any, Optional[Any]) -> None