Hello community,

here is the log from the commit of package python-addict for openSUSE:Factory 
checked in at 2020-09-15 16:29:18
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-addict (Old)
 and      /work/SRC/openSUSE:Factory/.python-addict.new.4249 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-addict"

Tue Sep 15 16:29:18 2020 rev:5 rq:834472 version:2.3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-addict/python-addict.changes      
2019-04-30 13:05:51.941909343 +0200
+++ /work/SRC/openSUSE:Factory/.python-addict.new.4249/python-addict.changes    
2020-09-15 16:29:22.162658782 +0200
@@ -1,0 +2,9 @@
+Tue Sep 15 05:07:38 UTC 2020 - Steve Kowalik <steven.kowa...@suse.com>
+
+- Update to 2.3.0:
+  * Document default value behaviour (#126)
+  * Add Python 3.9's merge operators `|` and `|=` support (#127) (#128)
+  * Add alias 'Addict' to import Dict (#118)
+- Switch to pytest to run tests
+
+-------------------------------------------------------------------

Old:
----
  v2.2.1.tar.gz

New:
----
  v2.3.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-addict.spec ++++++
--- /var/tmp/diff_new_pack.KM7RRq/_old  2020-09-15 16:29:23.086659667 +0200
+++ /var/tmp/diff_new_pack.KM7RRq/_new  2020-09-15 16:29:23.090659670 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-addict
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,13 +18,13 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-addict
-Version:        2.2.1
+Version:        2.3.0
 Release:        0
 Summary:        A dictionary using both attribute and item syntax
 License:        MIT
-Group:          Development/Languages/Python
 URL:            https://github.com/mewwts/addict
 Source:         https://github.com/mewwts/addict/archive/v%{version}.tar.gz
+BuildRequires:  %{python_module pytest}
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
@@ -47,7 +47,7 @@
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %check
-%python_exec setup.py test
+%pytest
 
 %files %{python_files}
 %doc README.md

++++++ v2.2.1.tar.gz -> v2.3.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/addict-2.2.1/README.md new/addict-2.3.0/README.md
--- old/addict-2.2.1/README.md  2019-04-28 10:12:41.000000000 +0200
+++ new/addict-2.3.0/README.md  2020-09-12 09:19:05.000000000 +0200
@@ -1,4 +1,4 @@
-# addict - the Python Dict that's better than heroin.
+# addict (maintainer wanted, please reach out.)
 [![build 
Status](https://travis-ci.org/mewwts/addict.svg?branch=master)](https://travis-ci.org/mewwts/addict)
 [![Coverage 
Status](https://img.shields.io/coveralls/mewwts/addict.svg)](https://coveralls.io/r/mewwts/addict)
 [![PyPI 
version](https://badge.fury.io/py/addict.svg)](https://badge.fury.io/py/addict) 
[![Anaconda-Server 
Badge](https://anaconda.org/conda-forge/addict/badges/version.svg)](https://anaconda.org/conda-forge/addict)
 [![Supportwith-Ether 
Badge](https://img.shields.io/badge/Support%20with-ETH-green.svg)](https://supportwith.xyz/ether/0x77D52D817bbb513F827e4E976D425f4FA1618350)
 
 addict is a Python module that gives you dictionaries whose values are both 
gettable and settable using attributes, in addition to standard item-syntax.
@@ -108,6 +108,17 @@
 ```
 just like a regular `dict`. There are no restrictions (other than what a 
regular dict imposes) regarding what keys you can use.
 
+### Default values
+For keys that are not in the dictionary, addict behaves like 
```defaultdict(Dict)```, so missing keys return an empty ```Dict```
+rather than raising ```KeyError```.
+If this behaviour is not desired, it can be overriden using
+```Python
+>>> class DictNoDefault(Dict):
+>>>     def __missing__(self, key):
+>>>         raise KeyError(key)
+```
+but beware that you will then lose the shorthand assignment functionality 
(```addicted.a.b.c.d.e = 2```).
+
 ### Recursive Fallback to dict
 If you don't feel safe shipping your addict around to other modules, use the 
`to_dict()`-method, which returns a regular dict clone of the addict dictionary.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/addict-2.2.1/addict/__init__.py 
new/addict-2.3.0/addict/__init__.py
--- old/addict-2.2.1/addict/__init__.py 2019-04-28 10:12:41.000000000 +0200
+++ new/addict-2.3.0/addict/__init__.py 2020-09-12 09:19:05.000000000 +0200
@@ -1,4 +1,5 @@
 from .addict import Dict
+from .addict import Dict as Addict
 
 
 __title__ = 'addict'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/addict-2.2.1/addict/addict.py 
new/addict-2.3.0/addict/addict.py
--- old/addict-2.2.1/addict/addict.py   2019-04-28 10:12:41.000000000 +0200
+++ new/addict-2.3.0/addict/addict.py   2020-09-12 09:19:05.000000000 +0200
@@ -117,6 +117,24 @@
     def __setstate__(self, state):
         self.update(state)
 
+    def __or__(self, other):
+        if not isinstance(other, (Dict, dict)):
+            return NotImplemented
+        new = Dict(self)
+        new.update(other)
+        return new
+
+    def __ror__(self, other):
+        if not isinstance(other, (Dict, dict)):
+            return NotImplemented
+        new = Dict(other)
+        new.update(self)
+        return new
+
+    def __ior__(self, other):
+        self.update(other)
+        return self
+
     def setdefault(self, key, default=None):
         if key in self:
             return self[key]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/addict-2.2.1/test_addict.py 
new/addict-2.3.0/test_addict.py
--- old/addict-2.2.1/test_addict.py     2019-04-28 10:12:41.000000000 +0200
+++ new/addict-2.3.0/test_addict.py     2020-09-12 09:19:05.000000000 +0200
@@ -267,6 +267,101 @@
             org.update({'a': 2}, {'a': 1})
         org = self.dict_class()
         self.assertRaises(TypeError, update)
+        
+    def test_ior_operator(self):
+        old = self.dict_class()
+        old.child.a = 'a'
+        old.child.b = 'b'
+        old.foo = 'c'
+
+        new = self.dict_class()
+        new.child.b = 'b2'
+        new.child.c = 'c'
+        new.foo.bar = True
+
+        old |= new
+
+        reference = {'foo': {'bar': True},
+                     'child': {'a': 'a', 'c': 'c', 'b': 'b2'}}
+
+        self.assertDictEqual(old, reference)
+
+    def test_ior_operator_with_lists(self):
+        org = self.dict_class()
+        org.a = [1, 2, {'a': 'superman'}]
+        someother = self.dict_class()
+        someother.b = [{'b': 123}]
+        org |= someother
+
+        correct = {'a': [1, 2, {'a': 'superman'}],
+                   'b': [{'b': 123}]}
+
+        org |= someother
+        self.assertDictEqual(org, correct)
+        self.assertIsInstance(org.b[0], dict)
+
+    def test_ior_operator_with_dict(self):
+        org = self.dict_class(one=1, two=2)
+        someother = self.dict_class(one=3)
+        someother |= dict(one=1, two=2)
+        self.assertDictEqual(org, someother)
+
+    def test_or_operator(self):
+        old = self.dict_class()
+        old.child.a = 'a'
+        old.child.b = 'b'
+        old.foo = 'c'
+
+        new = self.dict_class()
+        new.child.b = 'b2'
+        new.child.c = 'c'
+        new.foo.bar = True
+
+        old = old | new
+
+        reference = {'foo': {'bar': True},
+                     'child': {'a': 'a', 'c': 'c', 'b': 'b2'}}
+
+        self.assertDictEqual(old, reference)
+
+    def test_or_operator_with_lists(self):
+        org = self.dict_class()
+        org.a = [1, 2, {'a': 'superman'}]
+        someother = self.dict_class()
+        someother.b = [{'b': 123}]
+        org = org | someother
+
+        correct = {'a': [1, 2, {'a': 'superman'}],
+                   'b': [{'b': 123}]}
+
+        org = org | someother
+        self.assertDictEqual(org, correct)
+        self.assertIsInstance(org.b[0], dict)
+    
+    def test_ror_operator(self):
+        org = dict()
+        org['a'] = [1, 2, {'a': 'superman'}]
+        someother = self.dict_class()
+        someother.b = [{'b': 123}]
+        org = org | someother
+
+        correct = {'a': [1, 2, {'a': 'superman'}],
+                   'b': [{'b': 123}]}
+
+        org = org | someother
+        self.assertDictEqual(org, correct)
+        self.assertIsInstance(org, Dict)
+        self.assertIsInstance(org.b[0], dict)
+  
+    def test_or_operator_type_error(self):
+        old = self.dict_class()
+        with self.assertRaises(TypeError):
+            old | 'test'
+
+    def test_ror_operator_type_error(self):
+        old = self.dict_class()
+        with self.assertRaises(TypeError):
+            'test' | old
 
     def test_hook_in_constructor(self):
         a_dict = self.dict_class(TEST_DICT)
@@ -415,7 +510,7 @@
             a[1].x = 3
         except Exception as e:
             self.fail(e)
-        self.assertEquals(a, {'keys': {'x': 1}, 1: {'x': 3}})
+        self.assertEqual(a, {'keys': {'x': 1}, 1: {'x': 3}})
 
     def test_parent_key_prop(self):
         a = self.dict_class()
@@ -423,7 +518,7 @@
             a.y.x = 1
         except AttributeError as e:
             self.fail(e)
-        self.assertEquals(a, {'y': {'x': 1}})
+        self.assertEqual(a, {'y': {'x': 1}})
 
 
 class DictTests(unittest.TestCase, AbstractTestsClass):


Reply via email to