From e1de4d45d365f64950eef7587eb688d1a3caff0f Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 20 Nov 2018 13:41:40 -0500 Subject: Rename .finalize() to .finish() --- README.rst | 4 ++-- immutables/_map.c | 2 +- immutables/map.py | 4 ++-- tests/test_map.py | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index 4f3d789..203f529 100644 --- a/README.rst +++ b/README.rst @@ -82,7 +82,7 @@ Maps also implement APIs for bulk updates: ``MapMutation`` objects:: del map_mutation['b'] map_mutation.set('y', 'y') - map2 = map_mutation.finalize() + map2 = map_mutation.finish() print(map, map2) # will print: @@ -96,7 +96,7 @@ rewritten in a more idiomatic way:: mm['a'] = 100 del mm['b'] mm.set('y', 'y') - map2 = mm.finalize() + map2 = mm.finish() print(map, map2) # will print: diff --git a/immutables/_map.c b/immutables/_map.c index 652e171..d5d7f97 100644 --- a/immutables/_map.c +++ b/immutables/_map.c @@ -3969,7 +3969,7 @@ static PyMethodDef MapMutation_methods[] = { {"set", (PyCFunction)mapmut_py_set, METH_VARARGS, NULL}, {"get", (PyCFunction)map_py_get, METH_VARARGS, NULL}, {"pop", (PyCFunction)mapmut_py_pop, METH_VARARGS, NULL}, - {"finalize", (PyCFunction)mapmut_py_finalize, METH_NOARGS, NULL}, + {"finish", (PyCFunction)mapmut_py_finalize, METH_NOARGS, NULL}, {"__enter__", (PyCFunction)mapmut_py_enter, METH_NOARGS, NULL}, {"__exit__", (PyCFunction)mapmut_py_exit, METH_VARARGS, NULL}, {NULL, NULL} diff --git a/immutables/map.py b/immutables/map.py index fbe6562..a393b72 100644 --- a/immutables/map.py +++ b/immutables/map.py @@ -637,7 +637,7 @@ class MapMutation: return self def __exit__(self, *exc): - self.finalize() + self.finish() return False def __delitem__(self, key): @@ -707,7 +707,7 @@ class MapMutation: else: return True - def finalize(self): + def finish(self): self.__mutid = 0 return Map._new(self.__count, self.__root) diff --git a/tests/test_map.py b/tests/test_map.py index d3b11fb..69684e8 100644 --- a/tests/test_map.py +++ b/tests/test_map.py @@ -943,8 +943,8 @@ class BaseMapTest: self.assertEqual(hm2['a'], 1000) self.assertTrue('x' in hm2) - h1 = hm1.finalize() - h2 = hm2.finalize() + h1 = hm1.finish() + h2 = hm2.finish() self.assertTrue(isinstance(h1, self.Map)) @@ -960,7 +960,7 @@ class BaseMapTest: hm1.set('a', 2) hm1.set('a', 3) hm1.set('a', 4) - h2 = hm1.finalize() + h2 = hm1.finish() self.assertEqual(dict(h.items()), {'a': 1}) self.assertEqual(dict(h2.items()), {'a': 4}) @@ -1124,22 +1124,22 @@ class BaseMapTest: mm = m.mutate() self.assertEqual(mm.pop('a', 1), 1) - self.assertEqual(mm.finalize(), self.Map({'b': 2})) + self.assertEqual(mm.finish(), self.Map({'b': 2})) mm = m.mutate() self.assertEqual(mm.pop('b', 1), 2) - self.assertEqual(mm.finalize(), self.Map({'a': 1})) + self.assertEqual(mm.finish(), self.Map({'a': 1})) mm = m.mutate() self.assertEqual(mm.pop('b', 1), 2) del mm['a'] - self.assertEqual(mm.finalize(), self.Map()) + self.assertEqual(mm.finish(), self.Map()) def test_map_mut_12(self): m = self.Map({'a': 1, 'b': 2}) mm = m.mutate() - mm.finalize() + mm.finish() with self.assertRaisesRegex(ValueError, 'has been finalized'): mm.pop('a') @@ -1181,7 +1181,7 @@ class BaseMapTest: mm['z'] = 100 del mm['a'] - self.assertEqual(mm.finalize(), self.Map(z=100, b=2)) + self.assertEqual(mm.finish(), self.Map(z=100, b=2)) def test_map_mut_15(self): m = self.Map(a=1, b=2) @@ -1192,7 +1192,7 @@ class BaseMapTest: del mm['a'] 1 / 0 - self.assertEqual(mm.finalize(), self.Map(z=100, b=2)) + self.assertEqual(mm.finish(), self.Map(z=100, b=2)) self.assertEqual(m, self.Map(a=1, b=2)) def test_map_mut_stress(self): @@ -1216,7 +1216,7 @@ class BaseMapTest: self.assertEqual(len(hm), len(d)) - h2 = hm.finalize() + h2 = hm.finish() self.assertEqual(dict(h2.items()), d) h = h2 @@ -1238,7 +1238,7 @@ class BaseMapTest: self.assertEqual(len(hm), len(d)) - h2 = hm.finalize() + h2 = hm.finish() self.assertEqual(dict(h2.items()), d) h = h2 -- cgit v1.2.3