Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-addict for openSUSE:Factory checked in at 2021-05-17 18:45:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-addict (Old) and /work/SRC/openSUSE:Factory/.python-addict.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-addict" Mon May 17 18:45:08 2021 rev:6 rq:893573 version:2.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-addict/python-addict.changes 2020-09-15 16:29:22.162658782 +0200 +++ /work/SRC/openSUSE:Factory/.python-addict.new.2988/python-addict.changes 2021-05-17 18:45:25.608595069 +0200 @@ -1,0 +2,6 @@ +Mon May 17 07:36:43 UTC 2021 - [email protected] + +- version update to 2.4.0 + * Calling .freeze() forbids getting/setting missing keys. Use .unfreeze() to undo. + +------------------------------------------------------------------- Old: ---- v2.3.0.tar.gz New: ---- v2.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-addict.spec ++++++ --- /var/tmp/diff_new_pack.mvdzgY/_old 2021-05-17 18:45:26.168592693 +0200 +++ /var/tmp/diff_new_pack.mvdzgY/_new 2021-05-17 18:45:26.168592693 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-addict # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-addict -Version: 2.3.0 +Version: 2.4.0 Release: 0 Summary: A dictionary using both attribute and item syntax License: MIT ++++++ v2.3.0.tar.gz -> v2.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/addict-2.3.0/.github/workflows/python-app.yml new/addict-2.4.0/.github/workflows/python-app.yml --- old/addict-2.3.0/.github/workflows/python-app.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/addict-2.4.0/.github/workflows/python-app.yml 2020-11-21 17:18:30.000000000 +0100 @@ -0,0 +1,31 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [2.7, 3.6, 3.7, 3.8, pypy2, pypy3] + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + - name: Test with pytest + run: | + pytest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/addict-2.3.0/README.md new/addict-2.4.0/README.md --- old/addict-2.3.0/README.md 2020-09-12 09:19:05.000000000 +0200 +++ new/addict-2.4.0/README.md 2020-11-21 17:18:30.000000000 +0100 @@ -1,5 +1,5 @@ -# addict (maintainer wanted, please reach out.) -[](https://travis-ci.org/mewwts/addict) [](https://coveralls.io/r/mewwts/addict) [](https://badge.fury.io/py/addict) [](https://anaconda.org/conda-forge/addict) [](https://supportwith.xyz/ether/0x77D52D817bbb513F827e4E976D425f4FA1618350) +# addict + [](https://coveralls.io/r/mewwts/addict) [](https://badge.fury.io/py/addict) [](https://anaconda.org/conda-forge/addict) addict is a Python module that gives you dictionaries whose values are both gettable and settable using attributes, in addition to standard item-syntax. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/addict-2.3.0/addict/__init__.py new/addict-2.4.0/addict/__init__.py --- old/addict-2.3.0/addict/__init__.py 2020-09-12 09:19:05.000000000 +0200 +++ new/addict-2.4.0/addict/__init__.py 2020-11-21 17:18:30.000000000 +0100 @@ -3,8 +3,8 @@ __title__ = 'addict' -__version__ = '2.2.1' +__version__ = '2.4.0' __author__ = 'Mats Julian Olsen' __license__ = 'MIT' -__copyright__ = 'Copyright 2014, 2015, 2016 Mats Julian Olsen' +__copyright__ = 'Copyright 2014-2020 Mats Julian Olsen' __all__ = ['Dict'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/addict-2.3.0/addict/addict.py new/addict-2.4.0/addict/addict.py --- old/addict-2.3.0/addict/addict.py 2020-09-12 09:19:05.000000000 +0200 +++ new/addict-2.4.0/addict/addict.py 2020-11-21 17:18:30.000000000 +0100 @@ -6,6 +6,7 @@ def __init__(__self, *args, **kwargs): object.__setattr__(__self, '__parent', kwargs.pop('__parent', None)) object.__setattr__(__self, '__key', kwargs.pop('__key', None)) + object.__setattr__(__self, '__frozen', False) for arg in args: if not arg: continue @@ -29,6 +30,10 @@ self[name] = value def __setitem__(self, name, value): + isFrozen = (hasattr(self, '__frozen') and + object.__getattribute__(self, '__frozen')) + if isFrozen and name not in super(Dict, self).keys(): + raise KeyError(name) super(Dict, self).__setitem__(name, value) try: p = object.__getattribute__(self, '__parent') @@ -62,6 +67,8 @@ return self.__getitem__(item) def __missing__(self, name): + if object.__getattribute__(self, '__frozen'): + raise KeyError(name) return self.__class__(__parent=self, __key=name) def __delattr__(self, name): @@ -141,3 +148,12 @@ else: self[key] = default return default + + def freeze(self, shouldFreeze=True): + object.__setattr__(self, '__frozen', shouldFreeze) + for key, val in self.items(): + if isinstance(val, Dict): + val.freeze(shouldFreeze) + + def unfreeze(self): + self.freeze(False) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/addict-2.3.0/setup.py new/addict-2.4.0/setup.py --- old/addict-2.3.0/setup.py 2020-09-12 09:19:05.000000000 +0200 +++ new/addict-2.4.0/setup.py 2020-11-21 17:18:30.000000000 +0100 @@ -18,6 +18,8 @@ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Intended Audience :: Developers', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/addict-2.3.0/test_addict.py new/addict-2.4.0/test_addict.py --- old/addict-2.3.0/test_addict.py 2020-09-12 09:19:05.000000000 +0200 +++ new/addict-2.4.0/test_addict.py 2020-11-21 17:18:30.000000000 +0100 @@ -520,6 +520,57 @@ self.fail(e) self.assertEqual(a, {'y': {'x': 1}}) + def test_top_freeze_against_top_key(self): + "Test that d.freeze() produces KeyError on d.missing." + d = self.dict_class() + self.assertEqual(d.missing, {}) + d.freeze() + with self.assertRaises(KeyError): + d.missing + d.unfreeze() + self.assertEqual(d.missing, {}) + + def test_top_freeze_against_nested_key(self): + "Test that d.freeze() produces KeyError on d.inner.missing." + d = self.dict_class() + d.inner.present = TEST_VAL + self.assertIn("inner", d) + self.assertEqual(d.inner.missing, {}) + d.freeze() + with self.assertRaises(KeyError): + d.inner.missing + with self.assertRaises(KeyError): + d.missing + d.unfreeze() + self.assertEqual(d.inner.missing, {}) + self.assertEqual(d.missing, {}) + + def test_nested_freeze_against_top_level(self): + "Test that d.inner.freeze() leaves top-level `d` unfrozen." + d = self.dict_class() + d.inner.present = TEST_VAL + self.assertEqual(d.inner.present, TEST_VAL) + self.assertEqual(d.inner.missing, {}) + self.assertEqual(d.missing, {}) + d.inner.freeze() + with self.assertRaises(KeyError): + d.inner.missing # d.inner is frozen + self.assertEqual(d.missing, {}) # but not `d` itself + d.inner.unfreeze() + self.assertEqual(d.inner.missing, {}) + + def test_top_freeze_disallows_new_key_addition(self): + "Test that d.freeze() disallows adding new keys in d." + d = self.dict_class({"oldKey": None}) + d.freeze() + d.oldKey = TEST_VAL # Can set pre-existing key. + self.assertEqual(d.oldKey, TEST_VAL) + with self.assertRaises(KeyError): + d.newKey = TEST_VAL # But can't add a new key. + self.assertNotIn("newKey", d) + d.unfreeze() + d.newKey = TEST_VAL + self.assertEqual(d.newKey, TEST_VAL) class DictTests(unittest.TestCase, AbstractTestsClass): dict_class = Dict
