Hello community, here is the log from the commit of package python-zict for openSUSE:Leap:15.2 checked in at 2020-03-20 05:15:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-zict (Old) and /work/SRC/openSUSE:Leap:15.2/.python-zict.new.3160 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-zict" Fri Mar 20 05:15:12 2020 rev:13 rq:786433 version:2.0.0 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-zict/python-zict.changes 2020-03-02 13:25:18.758631621 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-zict.new.3160/python-zict.changes 2020-03-20 05:15:17.418563514 +0100 @@ -1,0 +2,12 @@ +Mon Mar 9 10:51:00 UTC 2020 - [email protected] + +- version update to 2.0.0 + * Create CONTRIBUTING.md (:pr:`28`) Jacob Tomlinson + * Import ABC from collections.abc instead of collections for Python 3.9 compatibility (:pr:`31`) Karthikeyan Singaravelan + * Drop Python 2 / 3.5 and add Python 3.7 / 3.8 support (:pr:`34`) James Bourbeau + * Duplicate keys fast slow (:pr:`32`) fjetter + * Fix dask cuda worker's race condition failure (:pr:`33`) Pradipta Ghosh + * Changed default lmdb encoding to utf-8 (:pr:`36`) Alex Davies + * Add code linting and style check (:pr:`35`) James Bourbeau + +------------------------------------------------------------------- Old: ---- zict-1.0.0.tar.gz New: ---- zict-2.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-zict.spec ++++++ --- /var/tmp/diff_new_pack.aMgaGt/_old 2020-03-20 05:15:18.190564033 +0100 +++ /var/tmp/diff_new_pack.aMgaGt/_new 2020-03-20 05:15:18.202564041 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-zict # -# 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 @@ -17,8 +17,9 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} +%define skip_python2 1 Name: python-zict -Version: 1.0.0 +Version: 2.0.0 Release: 0 Summary: Mutable mapping tools License: BSD-3-Clause ++++++ zict-1.0.0.tar.gz -> zict-2.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/PKG-INFO new/zict-2.0.0/PKG-INFO --- old/zict-1.0.0/PKG-INFO 2019-06-25 08:58:10.000000000 +0200 +++ new/zict-2.0.0/PKG-INFO 2020-02-28 16:22:17.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: zict -Version: 1.0.0 +Version: 2.0.0 Summary: Mutable mapping tools Home-page: http://zict.readthedocs.io/en/latest/ Maintainer: Matthew Rocklin @@ -19,3 +19,7 @@ Keywords: mutable mapping,dict,dask Platform: UNKNOWN +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/setup.cfg new/zict-2.0.0/setup.cfg --- old/zict-1.0.0/setup.cfg 2019-06-25 08:58:10.000000000 +0200 +++ new/zict-2.0.0/setup.cfg 2020-02-28 16:22:17.000000000 +0100 @@ -1,3 +1,13 @@ +[flake8] +exclude = __init__.py +max-line-length = 120 +ignore = + E731, # Assigning lambda expression + E741 # Ambiguous variable names + +[tool:pytest] +addopts = -v --doctest-modules + [egg_info] tag_build = tag_date = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/setup.py new/zict-2.0.0/setup.py --- old/zict-1.0.0/setup.py 2019-06-25 08:56:50.000000000 +0200 +++ new/zict-2.0.0/setup.py 2020-02-28 16:20:44.000000000 +0100 @@ -4,7 +4,7 @@ from setuptools import setup setup(name='zict', - version='1.0.0', + version='2.0.0', description='Mutable mapping tools', url='http://zict.readthedocs.io/en/latest/', maintainer='Matthew Rocklin', @@ -15,4 +15,10 @@ install_requires=open('requirements.txt').read().strip().split('\n'), long_description=(open('README.rst').read() if os.path.exists('README.rst') else ''), + classifiers=[ + "Programming Language :: Python", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + ], zip_safe=False) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/__init__.py new/zict-2.0.0/zict/__init__.py --- old/zict-1.0.0/zict/__init__.py 2019-06-25 08:56:58.000000000 +0200 +++ new/zict-2.0.0/zict/__init__.py 2020-02-28 16:20:44.000000000 +0100 @@ -6,4 +6,4 @@ from .sieve import Sieve from .lmdb import LMDB -__version__ = '1.0.0' +__version__ = "2.0.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/buffer.py new/zict-2.0.0/zict/buffer.py --- old/zict-1.0.0/zict/buffer.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/buffer.py 2020-02-27 21:54:41.000000000 +0100 @@ -35,8 +35,16 @@ -------- LRU """ - def __init__(self, fast, slow, n, weight=lambda k, v: 1, - fast_to_slow_callbacks=None, slow_to_fast_callbacks=None): + + def __init__( + self, + fast, + slow, + n, + weight=lambda k, v: 1, + fast_to_slow_callbacks=None, + slow_to_fast_callbacks=None, + ): self.fast = LRU(n, fast, weight=weight, on_evict=[self.fast_to_slow]) self.slow = slow self.n = n @@ -72,13 +80,14 @@ raise KeyError(key) def __setitem__(self, key, value): - weight = self.weight(key, value) # Avoid useless movement for heavy values if self.weight(key, value) <= self.n: if key in self.slow: del self.slow[key] self.fast[key] = value else: + if key in self.fast: + del self.fast[key] self.slow[key] = value def __delitem__(self, key): @@ -108,7 +117,7 @@ return key in self.fast or key in self.slow def __str__(self): - return 'Buffer<%s, %s>' % (str(self.fast), str(self.slow)) + return "Buffer<%s, %s>" % (str(self.fast), str(self.slow)) __repr__ = __str__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/common.py new/zict-2.0.0/zict/common.py --- old/zict-1.0.0/zict/common.py 2019-03-09 17:34:21.000000000 +0100 +++ new/zict-2.0.0/zict/common.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - try: from collections.abc import Mapping, MutableMapping except ImportError: @@ -14,13 +12,13 @@ def update(*args, **kwds): # Boilerplate for implementing an update() method if not args: - raise TypeError("descriptor 'update' of MutableMapping object " - "needs an argument") + raise TypeError( + "descriptor 'update' of MutableMapping object " "needs an argument" + ) self = args[0] args = args[1:] if len(args) > 1: - raise TypeError('update expected at most 1 arguments, got %d' % - len(args)) + raise TypeError("update expected at most 1 arguments, got %d" % len(args)) items = [] if args: other = args[0] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/file.py new/zict-2.0.0/zict/file.py --- old/zict-1.0.0/zict/file.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/file.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,11 +1,5 @@ -from __future__ import absolute_import, division, print_function - -import errno import os -try: - from urllib.parse import quote, unquote -except ImportError: - from urllib import quote, unquote +from urllib.parse import quote, unquote from .common import ZictBase @@ -15,7 +9,7 @@ Escape key so as to be usable on all filesystems. """ # Even directory separators are unsafe. - return quote(key, safe='') + return quote(key, safe="") def _unsafe_key(key): @@ -55,29 +49,34 @@ >>> z['data'] = np.ones(5).data # doctest: +SKIP """ - def __init__(self, directory, mode='a'): + + def __init__(self, directory, mode="a"): self.directory = directory self.mode = mode self._keys = set() if not os.path.exists(self.directory): - os.mkdir(self.directory) + os.makedirs(self.directory, exist_ok=True) else: for n in os.listdir(self.directory): self._keys.add(_unsafe_key(n)) def __str__(self): - return '<File: %s, mode="%s", %d elements>' % (self.directory, self.mode, len(self)) + return '<File: %s, mode="%s", %d elements>' % ( + self.directory, + self.mode, + len(self), + ) __repr__ = __str__ def __getitem__(self, key): if key not in self._keys: raise KeyError(key) - with open(os.path.join(self.directory, _safe_key(key)), 'rb') as f: + with open(os.path.join(self.directory, _safe_key(key)), "rb") as f: return f.read() def __setitem__(self, key, value): - with open(os.path.join(self.directory, _safe_key(key)), 'wb') as f: + with open(os.path.join(self.directory, _safe_key(key)), "wb") as f: if isinstance(value, (tuple, list)): for v in value: f.write(v) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/func.py new/zict-2.0.0/zict/func.py --- old/zict-1.0.0/zict/func.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/func.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import ZictBase, close @@ -30,6 +28,7 @@ >>> f['x'] 10.0 """ + def __init__(self, dump, load, d): self.dump = dump self.load = load @@ -66,9 +65,11 @@ return len(self.d) def __str__(self): - return '<Func: %s<->%s %s>' % (funcname(self.dump), - funcname(self.load), - str(self.d)) + return "<Func: %s<->%s %s>" % ( + funcname(self.dump), + funcname(self.load), + str(self.d), + ) __repr__ = __str__ @@ -81,9 +82,9 @@ def funcname(func): """Get the name of a function.""" - while hasattr(func, 'func'): + while hasattr(func, "func"): func = func.func try: return func.__name__ - except: + except Exception: return str(func) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/lmdb.py new/zict-2.0.0/zict/lmdb.py --- old/zict-1.0.0/zict/lmdb.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/lmdb.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,24 +1,14 @@ -from __future__ import absolute_import, division, print_function - -import os import sys from .common import ZictBase -if sys.version_info >= (3,): - def _encode_key(key): - return key.encode('latin1') - - def _decode_key(key): - return key.decode('latin1') - -else: - def _encode_key(key): - return key +def _encode_key(key): + return key.encode("utf-8") + - def _decode_key(key): - return key +def _decode_key(key): + return key.decode("utf-8") class LMDB(ZictBase): @@ -37,20 +27,19 @@ >>> z['x'] # doctest: +SKIP b'123' """ + def __init__(self, directory): import lmdb + # map_size is the maximum database size but shouldn't fill up the # virtual address space - map_size = (1 << 40 if sys.maxsize >= 2**32 else 1 << 28) + map_size = 1 << 40 if sys.maxsize >= 2 ** 32 else 1 << 28 # writemap requires sparse file support otherwise the whole # `map_size` may be reserved up front on disk - writemap = sys.platform.startswith('linux') - self.db = lmdb.open(directory, - subdir=True, - map_size=map_size, - sync=False, - writemap=writemap, - ) + writemap = sys.platform.startswith("linux") + self.db = lmdb.open( + directory, subdir=True, map_size=map_size, sync=False, writemap=writemap, + ) def __getitem__(self, key): with self.db.begin() as txn: @@ -69,13 +58,11 @@ def items(self): cursor = self.db.begin().cursor() - return ((_decode_key(k), v) - for k, v in cursor.iternext(keys=True, values=True)) + return ((_decode_key(k), v) for k, v in cursor.iternext(keys=True, values=True)) def keys(self): cursor = self.db.begin().cursor() - return (_decode_key(k) - for k in cursor.iternext(keys=True, values=False)) + return (_decode_key(k) for k in cursor.iternext(keys=True, values=False)) def values(self): cursor = self.db.begin().cursor() @@ -97,7 +84,7 @@ raise KeyError(key) def __len__(self): - return self.db.stat()['entries'] + return self.db.stat()["entries"] def close(self): self.db.close() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/lru.py new/zict-2.0.0/zict/lru.py --- old/zict-1.0.0/zict/lru.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/lru.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from heapdict import heapdict from .common import ZictBase, close @@ -32,6 +30,7 @@ >>> lru['z'] = 3 Lost x 1 """ + def __init__(self, n, d, on_evict=None, weight=lambda k, v: 1): self.d = d self.n = n @@ -114,8 +113,8 @@ return key in self.d def __str__(self): - sub = str(self.d) if not isinstance(self.d, dict) else 'dict' - return '<LRU: %s/%s on %s>' % (self.total_weight, self.n, sub) + sub = str(self.d) if not isinstance(self.d, dict) else "dict" + return "<LRU: %s/%s on %s>" % (self.total_weight, self.n, sub) __repr__ = __str__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/sieve.py new/zict-2.0.0/zict/sieve.py --- old/zict-1.0.0/zict/sieve.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/sieve.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,8 +1,5 @@ -from __future__ import absolute_import, division, print_function - from collections import defaultdict from itertools import chain -import sys from .common import ZictBase, close @@ -33,6 +30,7 @@ -------- Buffer """ + def __init__(self, mappings, selector): self.mappings = mappings self.selector = selector @@ -55,7 +53,6 @@ def _do_update(self, items): # Optimized update() implementation issuing a single update() # call per underlying mapping. - to_delete = [] updates = defaultdict(list) mapping_ids = dict((id(m), m) for m in self.mappings.values()) @@ -91,7 +88,7 @@ return key in self.key_to_mapping def __str__(self): - return 'Sieve<%s>' % (str(self.mappings),) + return "Sieve<%s>" % (str(self.mappings),) __repr__ = __str__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_buffer.py new/zict-2.0.0/zict/tests/test_buffer.py --- old/zict-1.0.0/zict/tests/test_buffer.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_buffer.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from zict import Buffer from . import utils_test @@ -9,45 +7,45 @@ b = dict() buff = Buffer(a, b, n=10, weight=lambda k, v: v) - buff['x'] = 1 - buff['y'] = 2 + buff["x"] = 1 + buff["y"] = 2 - assert buff['x'] == 1 - assert buff['y'] == 2 - assert a == {'x': 1, 'y': 2} + assert buff["x"] == 1 + assert buff["y"] == 2 + assert a == {"x": 1, "y": 2} assert buff.fast.total_weight == 3 - buff['z'] = 8 - assert a == {'y': 2, 'z': 8} - assert b == {'x': 1} - - assert buff['x'] == 1 - assert a == {'x': 1, 'z': 8} - assert b == {'y': 2} - - assert 'x' in buff - assert 'y' in buff - assert 'missing' not in buff + buff["z"] = 8 + assert a == {"y": 2, "z": 8} + assert b == {"x": 1} + + assert buff["x"] == 1 + assert a == {"x": 1, "z": 8} + assert b == {"y": 2} + + assert "x" in buff + assert "y" in buff + assert "missing" not in buff - buff['y'] = 1 - assert a == {'x': 1, 'y': 1, 'z': 8} + buff["y"] = 1 + assert a == {"x": 1, "y": 1, "z": 8} assert buff.fast.total_weight == 10 assert b == {} - del buff['z'] - assert a == {'x': 1, 'y': 1} + del buff["z"] + assert a == {"x": 1, "y": 1} assert buff.fast.total_weight == 2 assert b == {} - del buff['y'] - assert a == {'x': 1} + del buff["y"] + assert a == {"x": 1} assert buff.fast.total_weight == 1 assert b == {} - assert 'y' not in buff + assert "y" not in buff - buff['a'] = 5 - assert set(buff) == set(buff.keys()) == {'a', 'x'} + buff["a"] = 5 + assert set(buff) == set(buff.keys()) == {"a", "x"} fast_keys = set(buff.fast) slow_keys = set(buff.slow) @@ -55,12 +53,34 @@ assert fast_keys | slow_keys == set(buff) # Overweight element stays in slow mapping - buff['b'] = 1000 - assert 'b' in buff.slow + buff["b"] = 1000 + assert "b" in buff.slow assert set(buff.fast) == fast_keys - assert set(buff.slow) == {'b'} | slow_keys - assert 'b' in buff - assert buff['b'] == 1000 + assert set(buff.slow) == {"b"} | slow_keys + assert "b" in buff + assert buff["b"] == 1000 + + +def test_setitem_avoid_fast_slow_duplicate(): + + a = dict() + b = dict() + buff = Buffer(a, b, n=10, weight=lambda k, v: v) + for first, second in [(1, 12), (12, 1)]: + buff["a"] = first + assert buff["a"] == first + buff["a"] = second + assert buff["a"] == second + + fast_keys = set(buff.fast) + slow_keys = set(buff.slow) + assert not (fast_keys & slow_keys) + assert fast_keys | slow_keys == set(buff) + + del buff["a"] + assert "a" not in buff + assert "a" not in a + assert "a" not in b def test_mapping(): @@ -76,36 +96,43 @@ def test_callbacks(): f2s = [] + def f2s_cb(k, v): f2s.append(k) s2f = [] + def s2f_cb(k, v): s2f.append(k) a = dict() b = dict() - buff = Buffer(a, b, n=10, weight=lambda k, v: v, - fast_to_slow_callbacks=f2s_cb, - slow_to_fast_callbacks=s2f_cb) + buff = Buffer( + a, + b, + n=10, + weight=lambda k, v: v, + fast_to_slow_callbacks=f2s_cb, + slow_to_fast_callbacks=s2f_cb, + ) - buff['x'] = 1 - buff['y'] = 2 + buff["x"] = 1 + buff["y"] = 2 - assert buff['x'] == 1 - assert buff['y'] == 2 + assert buff["x"] == 1 + assert buff["y"] == 2 assert not f2s assert not s2f - buff['z'] = 8 + buff["z"] = 8 - assert f2s == ['x'] + assert f2s == ["x"] assert s2f == [] - buff['z'] + buff["z"] - assert f2s == ['x'] + assert f2s == ["x"] assert s2f == [] - buff['x'] - assert f2s == ['x', 'y'] - assert s2f == ['x'] + buff["x"] + assert f2s == ["x", "y"] + assert s2f == ["x"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_file.py new/zict-2.0.0/zict/tests/test_file.py --- old/zict-1.0.0/zict/tests/test_file.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_file.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - import os import shutil @@ -11,7 +9,7 @@ @pytest.yield_fixture def fn(): - filename = '.tmp' + filename = ".tmp" if os.path.exists(filename): shutil.rmtree(filename) @@ -33,12 +31,12 @@ z = File(fn) assert not z - z['x'] = b'123' - assert os.listdir(fn) == ['x'] - with open(os.path.join(fn, 'x'), 'rb') as f: - assert f.read() == b'123' + z["x"] = b"123" + assert os.listdir(fn) == ["x"] + with open(os.path.join(fn, "x"), "rb") as f: + assert f.read() == b"123" - assert 'x' in z + assert "x" in z def test_str(fn): @@ -52,31 +50,31 @@ def test_setitem_typeerror(fn): z = File(fn) with pytest.raises(TypeError): - z['x'] = 123 + z["x"] = 123 def test_contextmanager(fn): with File(fn) as z: - z['x'] = b'123' + z["x"] = b"123" - with open(os.path.join(fn, 'x'), 'rb') as f: - assert f.read() == b'123' + with open(os.path.join(fn, "x"), "rb") as f: + assert f.read() == b"123" def test_delitem(fn): z = File(fn) - z['x'] = b'123' - assert os.path.exists(os.path.join(z.directory, 'x')) - del z['x'] - assert not os.path.exists(os.path.join(z.directory, 'x')) + z["x"] = b"123" + assert os.path.exists(os.path.join(z.directory, "x")) + del z["x"] + assert not os.path.exists(os.path.join(z.directory, "x")) def test_missing_key(fn): z = File(fn) with pytest.raises(KeyError): - z['x'] + z["x"] def test_arbitrary_chars(fn): @@ -85,22 +83,22 @@ # Avoid hitting the Windows max filename length chunk = 16 for i in range(1, 128, chunk): - key = ''.join(['foo_'] + [chr(i) for i in range(i, min(128, i + chunk))]) + key = "".join(["foo_"] + [chr(i) for i in range(i, min(128, i + chunk))]) with pytest.raises(KeyError): z[key] - z[key] = b'foo' - assert z[key] == b'foo' + z[key] = b"foo" + assert z[key] == b"foo" assert list(z) == [key] assert list(z.keys()) == [key] - assert list(z.items()) == [(key, b'foo')] - assert list(z.values()) == [b'foo'] + assert list(z.items()) == [(key, b"foo")] + assert list(z.values()) == [b"foo"] zz = File(fn) - assert zz[key] == b'foo' + assert zz[key] == b"foo" assert list(zz) == [key] assert list(zz.keys()) == [key] - assert list(zz.items()) == [(key, b'foo')] - assert list(zz.values()) == [b'foo'] + assert list(zz.items()) == [(key, b"foo")] + assert list(zz.values()) == [b"foo"] del zz del z[key] @@ -111,5 +109,5 @@ def test_write_list_of_bytes(fn): z = File(fn) - z['x'] = [b'123', b'4567'] - assert z['x'] == b'1234567' + z["x"] = [b"123", b"4567"] + assert z["x"] == b"1234567" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_func.py new/zict-2.0.0/zict/tests/test_func.py --- old/zict-1.0.0/zict/tests/test_func.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_func.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from zict import Func from . import utils_test @@ -7,12 +5,15 @@ def inc(x): return x + 1 + def dec(x): return x - 1 + def rotl(x): return x[1:] + x[:1] + def rotr(x): return x[-1:] + x[:-1] @@ -20,20 +21,20 @@ def test_simple(): d = dict() f = Func(inc, dec, d) - f['x'] = 10 - assert f['x'] == 10 - assert d['x'] == 11 + f["x"] = 10 + assert f["x"] == 10 + assert d["x"] == 11 - assert 'x' in f - assert list(f) == ['x'] + assert "x" in f + assert list(f) == ["x"] assert list(f.values()) == [10] - assert list(f.items()) == [('x', 10)] + assert list(f.items()) == [("x", 10)] - assert all(s in str(f) for s in ['inc', 'dec', 'x', 'Func']) - assert all(s in repr(f) for s in ['inc', 'dec', 'x', 'Func']) + assert all(s in str(f) for s in ["inc", "dec", "x", "Func"]) + assert all(s in repr(f) for s in ["inc", "dec", "x", "Func"]) - del f['x'] - assert 'x' not in d + del f["x"] + assert "x" not in d def test_mapping(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_lmdb.py new/zict-2.0.0/zict/tests/test_lmdb.py --- old/zict-1.0.0/zict/tests/test_lmdb.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_lmdb.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - import gc import os import shutil @@ -13,7 +11,7 @@ @pytest.yield_fixture def fn(): - dirname = tempfile.mkdtemp(prefix='test_lmdb-') + dirname = tempfile.mkdtemp(prefix="test_lmdb-") try: yield dirname finally: @@ -35,20 +33,20 @@ """ with LMDB(fn) as z: assert len(z) == 0 - z['abc'] = b'123' + z["abc"] = b"123" with LMDB(fn) as z: assert len(z) == 1 - assert z['abc'] == b'123' + assert z["abc"] == b"123" def test_creates_dir(fn): - with LMDB(fn) as z: + with LMDB(fn): assert os.path.isdir(fn) def test_file_descriptors_dont_leak(fn): - psutil = pytest.importorskip('psutil') + psutil = pytest.importorskip("psutil") proc = psutil.Process() before = proc.num_fds() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_lru.py new/zict-2.0.0/zict/tests/test_lru.py --- old/zict-1.0.0/zict/tests/test_lru.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_lru.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from zict import LRU from . import utils_test @@ -8,42 +6,42 @@ d = dict() lru = LRU(2, d) - lru['x'] = 1 - lru['y'] = 2 + lru["x"] = 1 + lru["y"] = 2 - assert lru['x'] == 1 - assert lru['y'] == 2 - assert d == {'x': 1, 'y': 2} + assert lru["x"] == 1 + assert lru["y"] == 2 + assert d == {"x": 1, "y": 2} - lru['z'] = 3 + lru["z"] = 3 assert len(d) == 2 assert len(lru) == 2 - assert 'z' in d - assert 'z' in lru - assert 'x' not in d - assert 'y' in d - - del lru['y'] - assert 'y' not in d - assert 'y' not in lru + assert "z" in d + assert "z" in lru + assert "x" not in d + assert "y" in d + + del lru["y"] + assert "y" not in d + assert "y" not in lru - lru['a'] = 5 - assert set(lru.keys()) == set(['z', 'a']) + lru["a"] = 5 + assert set(lru.keys()) == set(["z", "a"]) def test_str(): d = dict() lru = LRU(2, d) - lru['x'] = 1 - lru['y'] = 2 + lru["x"] = 1 + lru["y"] = 2 assert str(lru.total_weight) in str(lru) assert str(lru.total_weight) in repr(lru) assert str(lru.n) in str(lru) assert str(lru.n) in repr(lru) - assert 'dict' in str(lru) - assert 'dict' in repr(lru) + assert "dict" in str(lru) + assert "dict" in repr(lru) def test_mapping(): @@ -61,19 +59,20 @@ d = dict() lru = LRU(2, d) - lru['x'] = 1 - lru['y'] = 2 - lru['y'] = 3 + lru["x"] = 1 + lru["y"] = 2 + lru["y"] = 3 - assert set(lru) == {'x', 'y'} + assert set(lru) == {"x", "y"} - lru.update({'y': 4}) + lru.update({"y": 4}) - assert set(lru) == {'x', 'y'} + assert set(lru) == {"x", "y"} def test_callbacks(): count = [0] + def cb(k, v): count[0] += 1 @@ -81,11 +80,11 @@ d = dict() lru = LRU(2, d, on_evict=[lambda k, v: L.append((k, v)), cb]) - lru['x'] = 1 - lru['y'] = 2 - lru['z'] = 3 + lru["x"] = 1 + lru["y"] = 2 + lru["z"] = 3 - assert L == [('x', 1)] + assert L == [("x", 1)] assert count[0] == len(L) @@ -94,35 +93,35 @@ weight = lambda k, v: v lru = LRU(10, d, weight=weight) - lru['x'] = 5 + lru["x"] = 5 assert lru.total_weight == 5 - lru['y'] = 4 + lru["y"] = 4 assert lru.total_weight == 9 - lru['z'] = 3 - assert d == {'y': 4, 'z': 3} + lru["z"] = 3 + assert d == {"y": 4, "z": 3} assert lru.total_weight == 7 - del lru['z'] + del lru["z"] assert lru.total_weight == 4 - lru['a'] = 10000 - assert 'a' not in lru - assert d == {'y': 4} + lru["a"] = 10000 + assert "a" not in lru + assert d == {"y": 4} def test_explicit_evict(): d = dict() lru = LRU(10, d) - lru['x'] = 1 - lru['y'] = 2 + lru["x"] = 1 + lru["y"] = 2 - assert set(d) == {'x', 'y'} + assert set(d) == {"x", "y"} k, v, w = lru.evict() - assert set(d) == {'y'} - assert k == 'x' + assert set(d) == {"y"} + assert k == "x" assert v == 1 assert w == 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_sieve.py new/zict-2.0.0/zict/tests/test_sieve.py --- old/zict-1.0.0/zict/tests/test_sieve.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_sieve.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,7 +1,3 @@ -from __future__ import absolute_import, division, print_function - -import sys - from zict import Sieve from . import utils_test @@ -10,52 +6,56 @@ a = {} b = {} c = {} + def selector(k, v): return len(v) % 3 + mappings = {0: a, 1: b, 2: c} d = Sieve(mappings, selector) assert len(d) == 0 - d['u'] = b'the' - d['v'] = b'big' - d['w'] = b'brown' - d['x'] = b'fox' - d['y'] = b'jumps' - d['z'] = b'over' + d["u"] = b"the" + d["v"] = b"big" + d["w"] = b"brown" + d["x"] = b"fox" + d["y"] = b"jumps" + d["z"] = b"over" - assert d['u'] == b'the' - assert d['v'] == b'big' + assert d["u"] == b"the" + assert d["v"] == b"big" assert len(d) == 6 - assert sorted(d) == ['u', 'v', 'w', 'x', 'y', 'z'] - assert sorted(d.keys()) == ['u', 'v', 'w', 'x', 'y', 'z'] - assert sorted(d.values()) == sorted([b'the', b'big', b'brown', - b'fox', b'jumps', b'over']) - - assert a == {'u': b'the', 'v': b'big', 'x': b'fox'} - assert b == {'z': b'over'} - assert c == {'w': b'brown', 'y': b'jumps'} + assert sorted(d) == ["u", "v", "w", "x", "y", "z"] + assert sorted(d.keys()) == ["u", "v", "w", "x", "y", "z"] + assert sorted(d.values()) == sorted( + [b"the", b"big", b"brown", b"fox", b"jumps", b"over"] + ) + + assert a == {"u": b"the", "v": b"big", "x": b"fox"} + assert b == {"z": b"over"} + assert c == {"w": b"brown", "y": b"jumps"} # Changing existing keys can move values from one mapping to another. - d['w'] = b'lazy' - d['x'] = b'dog' - assert d['w'] == b'lazy' - assert d['x'] == b'dog' + d["w"] = b"lazy" + d["x"] = b"dog" + assert d["w"] == b"lazy" + assert d["x"] == b"dog" assert len(d) == 6 - assert sorted(d.values()) == sorted([b'the', b'big', b'lazy', - b'dog', b'jumps', b'over']) + assert sorted(d.values()) == sorted( + [b"the", b"big", b"lazy", b"dog", b"jumps", b"over"] + ) + + assert a == {"u": b"the", "v": b"big", "x": b"dog"} + assert b == {"w": b"lazy", "z": b"over"} + assert c == {"y": b"jumps"} - assert a == {'u': b'the', 'v': b'big', 'x': b'dog'} - assert b == {'w': b'lazy', 'z': b'over'} - assert c == {'y': b'jumps'} - - del d['v'] - del d['w'] + del d["v"] + del d["w"] assert len(d) == 4 - assert 'v' not in d - assert 'w' not in d - assert sorted(d.values()) == sorted([b'the', b'dog', b'jumps', b'over']) + assert "v" not in d + assert "w" not in d + assert sorted(d.values()) == sorted([b"the", b"dog", b"jumps", b"over"]) def test_mapping(): @@ -64,8 +64,10 @@ """ a = {} b = {} + def selector(key, value): return sum(bytearray(value)) & 1 + mappings = {0: a, 1: b} z = Sieve(mappings, selector) utils_test.check_mapping(z) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/test_zip.py new/zict-2.0.0/zict/tests/test_zip.py --- old/zict-1.0.0/zict/tests/test_zip.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/test_zip.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,14 +1,19 @@ -from collections import MutableMapping import os import zipfile +try: + from collections.abc import MutableMapping +except ImportError: + from collections import MutableMapping + import pytest from zict import Zip + @pytest.yield_fixture def fn(): - filename = '.tmp.zip' + filename = ".tmp.zip" if os.path.exists(filename): os.remove(filename) @@ -27,58 +32,58 @@ assert list(z.values()) == [] assert list(z.items()) == [] - z['x'] = b'123' - assert list(z) == list(z.keys()) == ['x'] - assert list(z.values()) == [b'123'] - assert list(z.items()) == [('x', b'123')] - assert z['x'] == b'123' + z["x"] = b"123" + assert list(z) == list(z.keys()) == ["x"] + assert list(z.values()) == [b"123"] + assert list(z.items()) == [("x", b"123")] + assert z["x"] == b"123" z.flush() - zz = zipfile.ZipFile(fn, mode='r') - assert zz.read('x') == b'123' + zz = zipfile.ZipFile(fn, mode="r") + assert zz.read("x") == b"123" - z['y'] = b'456' - assert z['y'] == b'456' + z["y"] = b"456" + assert z["y"] == b"456" def test_setitem_typeerror(fn): z = Zip(fn) with pytest.raises(TypeError): - z['x'] = 123 + z["x"] = 123 def test_contextmanager(fn): with Zip(fn) as z: - z['x'] = b'123' + z["x"] = b"123" - zz = zipfile.ZipFile(fn, mode='r') - assert zz.read('x') == b'123' + zz = zipfile.ZipFile(fn, mode="r") + assert zz.read("x") == b"123" def test_missing_key(fn): z = Zip(fn) with pytest.raises(KeyError): - z['x'] + z["x"] def test_close(fn): z = Zip(fn) - z['x'] = b'123' + z["x"] = b"123" z.close() - zz = zipfile.ZipFile(fn, mode='r') - assert zz.read('x') == b'123' + zz = zipfile.ZipFile(fn, mode="r") + assert zz.read("x") == b"123" with pytest.raises(IOError): - z['y'] = b'123' + z["y"] = b"123" def test_bytearray(fn): - data = bytearray(b'123') + data = bytearray(b"123") with Zip(fn) as z: - z['x'] = data + z["x"] = data with Zip(fn) as z: - assert z['x'] == b'123' + assert z["x"] == b"123" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/tests/utils_test.py new/zict-2.0.0/zict/tests/utils_test.py --- old/zict-1.0.0/zict/tests/utils_test.py 2019-02-06 22:58:58.000000000 +0100 +++ new/zict-2.0.0/zict/tests/utils_test.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,9 +1,11 @@ -from __future__ import absolute_import, division, print_function - -from collections import MutableMapping import random import string +try: + from collections.abc import MutableMapping +except ImportError: + from collections import MutableMapping + import pytest @@ -14,7 +16,7 @@ for i in range(n): nchars = r.randint(min_len, max_len) - s = ''.join(r.choice(chars) for _ in range(nchars)) + s = "".join(r.choice(chars) for _ in range(nchars)) l.append(s) return l @@ -24,7 +26,7 @@ if isinstance(s, bytes): return s else: - return s.encode('latin1') + return s.encode("latin1") def check_items(z, expected_items): @@ -44,8 +46,7 @@ r = random.Random(42) keys = list(string.ascii_lowercase) - values = [to_bytestring(s) - for s in generate_random_strings(len(keys), 1, 10)] + values = [to_bytestring(s) for s in generate_random_strings(len(keys), 1, 10)] z.clear() assert len(z) == 0 @@ -78,40 +79,40 @@ assert list(z.items()) == [] assert len(z) == 0 - z['abc'] = b'456' - z['xyz'] = b'12' + z["abc"] = b"456" + z["xyz"] = b"12" assert len(z) == 2 - assert z['abc'] == b'456' + assert z["abc"] == b"456" - check_items(z, [('abc', b'456'), ('xyz', b'12')]) + check_items(z, [("abc", b"456"), ("xyz", b"12")]) - assert 'abc' in z - assert 'xyz' in z - assert 'def' not in z + assert "abc" in z + assert "xyz" in z + assert "def" not in z with pytest.raises(KeyError): - z['def'] + z["def"] - z.update(xyz=b'707', uvw=b'000') - check_items(z, [('abc', b'456'), ('xyz', b'707'), ('uvw', b'000')]) - z.update([('xyz', b'654'), ('uvw', b'999')]) - check_items(z, [('abc', b'456'), ('xyz', b'654'), ('uvw', b'999')]) - z.update({'xyz': b'321'}) - check_items(z, [('abc', b'456'), ('xyz', b'321'), ('uvw', b'999')]) + z.update(xyz=b"707", uvw=b"000") + check_items(z, [("abc", b"456"), ("xyz", b"707"), ("uvw", b"000")]) + z.update([("xyz", b"654"), ("uvw", b"999")]) + check_items(z, [("abc", b"456"), ("xyz", b"654"), ("uvw", b"999")]) + z.update({"xyz": b"321"}) + check_items(z, [("abc", b"456"), ("xyz", b"321"), ("uvw", b"999")]) - del z['abc'] + del z["abc"] with pytest.raises(KeyError): - z['abc'] + z["abc"] with pytest.raises(KeyError): - del z['abc'] - assert 'abc' not in z - assert set(z) == {'uvw', 'xyz'} + del z["abc"] + assert "abc" not in z + assert set(z) == {"uvw", "xyz"} assert len(z) == 2 - z['def'] = b'\x00\xff' + z["def"] = b"\x00\xff" assert len(z) == 3 - assert z['def'] == b'\x00\xff' - assert 'def' in z + assert z["def"] == b"\x00\xff" + assert "def" in z stress_test_mapping_updates(z) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict/zip.py new/zict-2.0.0/zict/zip.py --- old/zict-1.0.0/zict/zip.py 2019-03-09 17:34:21.000000000 +0100 +++ new/zict-2.0.0/zict/zip.py 2020-02-27 21:54:41.000000000 +0100 @@ -1,10 +1,7 @@ -from __future__ import absolute_import, division, print_function - try: from collections.abc import MutableMapping except ImportError: from collections import MutableMapping -import sys import zipfile @@ -26,14 +23,15 @@ b'123' >>> z.flush() # flush and write metadata to disk # doctest: +SKIP """ - def __init__(self, filename, mode='a'): + + def __init__(self, filename, mode="a"): self.filename = filename self.mode = mode self._file = None @property def file(self): - if self.mode == 'closed': + if self.mode == "closed": raise IOError("File closed") if not self._file or not self._file.fp: self._file = zipfile.ZipFile(self.filename, mode=self.mode) @@ -43,7 +41,7 @@ return self.file.read(key) def __setitem__(self, key, value): - self.file.writestr(key, to_bytes(value)) + self.file.writestr(key, value) def keys(self): return (zi.filename for zi in self.file.filelist) @@ -52,8 +50,7 @@ return map(self.file.read, self.keys()) def items(self): - return ((zi.filename, self.file.read(zi.filename)) - for zi in self.file.filelist) + return ((zi.filename, self.file.read(zi.filename)) for zi in self.file.filelist) def __iter__(self): return self.keys() @@ -70,19 +67,10 @@ def close(self): self.flush() - self.mode = 'closed' + self.mode = "closed" def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() - - -if sys.version_info[0] == 2: - def to_bytes(x): - if isinstance(x, bytearray): - return bytes(x) - return x -else: - to_bytes = lambda x: x diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict.egg-info/PKG-INFO new/zict-2.0.0/zict.egg-info/PKG-INFO --- old/zict-1.0.0/zict.egg-info/PKG-INFO 2019-06-25 08:58:10.000000000 +0200 +++ new/zict-2.0.0/zict.egg-info/PKG-INFO 2020-02-28 16:22:17.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: zict -Version: 1.0.0 +Version: 2.0.0 Summary: Mutable mapping tools Home-page: http://zict.readthedocs.io/en/latest/ Maintainer: Matthew Rocklin @@ -19,3 +19,7 @@ Keywords: mutable mapping,dict,dask Platform: UNKNOWN +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zict-1.0.0/zict.egg-info/SOURCES.txt new/zict-2.0.0/zict.egg-info/SOURCES.txt --- old/zict-1.0.0/zict.egg-info/SOURCES.txt 2019-06-25 08:58:10.000000000 +0200 +++ new/zict-2.0.0/zict.egg-info/SOURCES.txt 2020-02-28 16:22:17.000000000 +0100 @@ -2,6 +2,7 @@ MANIFEST.in README.rst requirements.txt +setup.cfg setup.py zict/__init__.py zict/buffer.py
