Skip to content

Commit e1de4d4

Browse files
committed
Rename .finalize() to .finish()
1 parent d14e5e9 commit e1de4d4

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Maps also implement APIs for bulk updates: ``MapMutation`` objects::
8282
del map_mutation['b']
8383
map_mutation.set('y', 'y')
8484

85-
map2 = map_mutation.finalize()
85+
map2 = map_mutation.finish()
8686

8787
print(map, map2)
8888
# will print:
@@ -96,7 +96,7 @@ rewritten in a more idiomatic way::
9696
mm['a'] = 100
9797
del mm['b']
9898
mm.set('y', 'y')
99-
map2 = mm.finalize()
99+
map2 = mm.finish()
100100

101101
print(map, map2)
102102
# will print:

immutables/_map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3969,7 +3969,7 @@ static PyMethodDef MapMutation_methods[] = {
39693969
{"set", (PyCFunction)mapmut_py_set, METH_VARARGS, NULL},
39703970
{"get", (PyCFunction)map_py_get, METH_VARARGS, NULL},
39713971
{"pop", (PyCFunction)mapmut_py_pop, METH_VARARGS, NULL},
3972-
{"finalize", (PyCFunction)mapmut_py_finalize, METH_NOARGS, NULL},
3972+
{"finish", (PyCFunction)mapmut_py_finalize, METH_NOARGS, NULL},
39733973
{"__enter__", (PyCFunction)mapmut_py_enter, METH_NOARGS, NULL},
39743974
{"__exit__", (PyCFunction)mapmut_py_exit, METH_VARARGS, NULL},
39753975
{NULL, NULL}

immutables/map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def __enter__(self):
637637
return self
638638

639639
def __exit__(self, *exc):
640-
self.finalize()
640+
self.finish()
641641
return False
642642

643643
def __delitem__(self, key):
@@ -707,7 +707,7 @@ def __contains__(self, key):
707707
else:
708708
return True
709709

710-
def finalize(self):
710+
def finish(self):
711711
self.__mutid = 0
712712
return Map._new(self.__count, self.__root)
713713

tests/test_map.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,8 @@ def test_map_mut_1(self):
943943
self.assertEqual(hm2['a'], 1000)
944944
self.assertTrue('x' in hm2)
945945

946-
h1 = hm1.finalize()
947-
h2 = hm2.finalize()
946+
h1 = hm1.finish()
947+
h2 = hm2.finish()
948948

949949
self.assertTrue(isinstance(h1, self.Map))
950950

@@ -960,7 +960,7 @@ def test_map_mut_2(self):
960960
hm1.set('a', 2)
961961
hm1.set('a', 3)
962962
hm1.set('a', 4)
963-
h2 = hm1.finalize()
963+
h2 = hm1.finish()
964964

965965
self.assertEqual(dict(h.items()), {'a': 1})
966966
self.assertEqual(dict(h2.items()), {'a': 4})
@@ -1124,22 +1124,22 @@ def test_map_mut_11(self):
11241124

11251125
mm = m.mutate()
11261126
self.assertEqual(mm.pop('a', 1), 1)
1127-
self.assertEqual(mm.finalize(), self.Map({'b': 2}))
1127+
self.assertEqual(mm.finish(), self.Map({'b': 2}))
11281128

11291129
mm = m.mutate()
11301130
self.assertEqual(mm.pop('b', 1), 2)
1131-
self.assertEqual(mm.finalize(), self.Map({'a': 1}))
1131+
self.assertEqual(mm.finish(), self.Map({'a': 1}))
11321132

11331133
mm = m.mutate()
11341134
self.assertEqual(mm.pop('b', 1), 2)
11351135
del mm['a']
1136-
self.assertEqual(mm.finalize(), self.Map())
1136+
self.assertEqual(mm.finish(), self.Map())
11371137

11381138
def test_map_mut_12(self):
11391139
m = self.Map({'a': 1, 'b': 2})
11401140

11411141
mm = m.mutate()
1142-
mm.finalize()
1142+
mm.finish()
11431143

11441144
with self.assertRaisesRegex(ValueError, 'has been finalized'):
11451145
mm.pop('a')
@@ -1181,7 +1181,7 @@ def test_map_mut_14(self):
11811181
mm['z'] = 100
11821182
del mm['a']
11831183

1184-
self.assertEqual(mm.finalize(), self.Map(z=100, b=2))
1184+
self.assertEqual(mm.finish(), self.Map(z=100, b=2))
11851185

11861186
def test_map_mut_15(self):
11871187
m = self.Map(a=1, b=2)
@@ -1192,7 +1192,7 @@ def test_map_mut_15(self):
11921192
del mm['a']
11931193
1 / 0
11941194

1195-
self.assertEqual(mm.finalize(), self.Map(z=100, b=2))
1195+
self.assertEqual(mm.finish(), self.Map(z=100, b=2))
11961196
self.assertEqual(m, self.Map(a=1, b=2))
11971197

11981198
def test_map_mut_stress(self):
@@ -1216,7 +1216,7 @@ def test_map_mut_stress(self):
12161216

12171217
self.assertEqual(len(hm), len(d))
12181218

1219-
h2 = hm.finalize()
1219+
h2 = hm.finish()
12201220
self.assertEqual(dict(h2.items()), d)
12211221
h = h2
12221222

@@ -1238,7 +1238,7 @@ def test_map_mut_stress(self):
12381238

12391239
self.assertEqual(len(hm), len(d))
12401240

1241-
h2 = hm.finalize()
1241+
h2 = hm.finish()
12421242
self.assertEqual(dict(h2.items()), d)
12431243
h = h2
12441244

0 commit comments

Comments
 (0)