Selaa lähdekoodia

Convert to Python 3: `reduce()` -> `functools.reduce()`

Alois Mahdal 2 vuotta sitten
vanhempi
commit
956ed002a5
1 muutettua tiedostoa jossa 10 lisäystä ja 3 poistoa
  1. 10
    3
      sznqalibs/hoover.py

+ 10
- 3
sznqalibs/hoover.py Näytä tiedosto

@@ -1,6 +1,7 @@
1 1
 # coding=utf-8
2 2
 
3 3
 import collections
4
+import functools
4 5
 import csv
5 6
 import difflib
6 7
 import hashlib
@@ -58,8 +59,10 @@ def regression_test(argsrc, tests, driver_settings, cleanup_hack=None,
58 59
     tracker = Tracker()
59 60
     last_argset = None
60 61
 
61
-    all_classes = set(reduce(lambda a, b: a+b,
62
-                             [triple[1:] for triple in tests]))
62
+    all_classes = set(functools.reduce(
63
+        lambda a, b: a+b,
64
+        [triple[1:] for triple in tests]
65
+    ))
63 66
 
64 67
     counter = StatCounter()
65 68
 
@@ -955,7 +958,11 @@ class Tracker(dict):
955 958
         """
956 959
 
957 960
         def total_errors():
958
-            return reduce(lambda x, y: x + len(y), self._db.values(), 0)
961
+            return functools.reduce(
962
+                lambda x, y: x + len(y),
963
+                self._db.values(),
964
+                initial=0,
965
+            )
959 966
 
960 967
         stats = {
961 968
             "argsets": self.argsets_done,