From a4174282791b20cc99c92a0e336cf5e9f4c5972c Mon Sep 17 00:00:00 2001 From: Elmer de Looff Date: Mon, 9 Sep 2019 18:22:08 +0200 Subject: [PATCH 1/3] Uses six' iteritems rather than builtin method to ensure Python 3 compatibility. --- kalpa/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kalpa/__init__.py b/kalpa/__init__.py index bc3ec31..c245407 100644 --- a/kalpa/__init__.py +++ b/kalpa/__init__.py @@ -101,7 +101,7 @@ def __new__(mcs, name, bases, attrs): should_register = not attrs.pop('__abstract__', False) attributes = {'__child_cls__': None} branches = attributes['_BRANCHES'] = inherited_branches(bases) - for attr, value in attrs.iteritems(): + for attr, value in iteritems(attrs): if isinstance(value, DeclaredBranch): branches.update(value.generate_resources(attr)) else: From b6e04e25a853bf68f0032200d1608012cf1670ca Mon Sep 17 00:00:00 2001 From: Elmer de Looff Date: Mon, 9 Sep 2019 18:22:29 +0200 Subject: [PATCH 2/3] Imports functools to get at reduce function for Python 3 compatibility. --- kalpa/tests/test_branch.py | 5 +++-- kalpa/tests/test_traversal.py | 5 +++-- kalpa/tests/test_utils.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/kalpa/tests/test_branch.py b/kalpa/tests/test_branch.py index bc717e8..e857329 100644 --- a/kalpa/tests/test_branch.py +++ b/kalpa/tests/test_branch.py @@ -1,3 +1,4 @@ +import functools import itertools import operator @@ -97,8 +98,8 @@ def test_branch_alternate_loading(root, user, node_class): ('objects', 'leaf'), ('people', 'charlie'), ('people', 'eve')]) def test_branch_load_cache(root, key_path): """Retrieving the same object twice should provide the same one.""" - first = reduce(operator.getitem, key_path, root) - second = reduce(operator.getitem, key_path, root) + first = functools.reduce(operator.getitem, key_path, root) + second = functools.reduce(operator.getitem, key_path, root) assert first is second diff --git a/kalpa/tests/test_traversal.py b/kalpa/tests/test_traversal.py index 292a0e2..a6ebef8 100644 --- a/kalpa/tests/test_traversal.py +++ b/kalpa/tests/test_traversal.py @@ -1,5 +1,6 @@ """Tests compatiblity and integration with Pyramid's traversal utlities.""" +import functools import operator import pytest @@ -19,7 +20,7 @@ def test_find_root(root): ('/objects/apple/votes', ('objects', 'apple', 'votes'))]) def test_find_resource(root, path, keys): """Resolving paths yields the expected resource.""" - resource = reduce(operator.getitem, keys, root) + resource = functools.reduce(operator.getitem, keys, root) assert traversal.find_resource(root, path) == resource @@ -28,7 +29,7 @@ def test_find_resource(root, path, keys): (('objects', 'pear', 'votes'), '/objects/pear/votes')]) def test_resource_path(root, keys, path): """Resources generate the expected path.""" - resource = reduce(operator.getitem, keys, root) + resource = functools.reduce(operator.getitem, keys, root) assert traversal.resource_path(resource) == path diff --git a/kalpa/tests/test_utils.py b/kalpa/tests/test_utils.py index a5fbf97..29a5c22 100644 --- a/kalpa/tests/test_utils.py +++ b/kalpa/tests/test_utils.py @@ -1,3 +1,4 @@ +import functools import operator import pytest @@ -26,7 +27,7 @@ def test_util_lineage(root): def test_find_parent_by_class(root, selector, expected_key_path): """Finding a parent resource by its class.""" alice = root['people']['alice'] - expected = reduce(operator.getitem, expected_key_path, root) + expected = functools.reduce(operator.getitem, expected_key_path, root) assert parent_by_class(alice, selector) is expected @@ -37,7 +38,7 @@ def test_find_parent_by_class(root, selector, expected_key_path): def test_find_parent_by_class_name(root, selector, expected_key_path): """Finding a parent resource by its class name.""" alice = root['people']['alice'] - expected = reduce(operator.getitem, expected_key_path, root) + expected = functools.reduce(operator.getitem, expected_key_path, root) assert parent_by_class(alice, selector) is expected From 770356ac5aecdcd5edad71f81b71b2b00d20d62a Mon Sep 17 00:00:00 2001 From: Elmer de Looff Date: Mon, 9 Sep 2019 18:29:07 +0200 Subject: [PATCH 3/3] Micro version increase. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0864f1a..442fd99 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def contents(filename): setup( name='kalpa', - version='0.5.0', + version='0.5.1', packages=find_packages(), author='Elmer de Looff', author_email='elmer.delooff@gmail.com',