changeset 52673:abc327f9628b

pyupgrade: replace unnecessary lambdas in `collections.defaultdict()` calls This was rewritten by the `defaultdict_lambda` fixer in `pyupgrade`.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 06 Jan 2025 01:12:54 -0500
parents ab7b4fba8bde
children d903647abbd3
files contrib/perf-utils/subsetmaker.py contrib/synthrepo.py hgext/remotefilelog/basepack.py hgext/remotefilelog/shallowutil.py mercurial/revlogutils/debug.py tests/test-pathencode.py
diffstat 6 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf-utils/subsetmaker.py	Mon Jan 06 01:06:59 2025 -0500
+++ b/contrib/perf-utils/subsetmaker.py	Mon Jan 06 01:12:54 2025 -0500
@@ -83,7 +83,7 @@
 
     selected = set()
     heads = SortedSet()
-    children_count = collections.defaultdict(lambda: 0)
+    children_count = collections.defaultdict(int)
     parents = repo.changelog._uncheckedparentrevs
 
     baseset = revset.getset(repo, smartset.fullreposet(repo), x)
--- a/contrib/synthrepo.py	Mon Jan 06 01:06:59 2025 -0500
+++ b/contrib/synthrepo.py	Mon Jan 06 01:12:54 2025 -0500
@@ -76,7 +76,7 @@
 
 
 def zerodict():
-    return collections.defaultdict(lambda: 0)
+    return collections.defaultdict(int)
 
 
 def roundto(x, k):
--- a/hgext/remotefilelog/basepack.py	Mon Jan 06 01:06:59 2025 -0500
+++ b/hgext/remotefilelog/basepack.py	Mon Jan 06 01:12:54 2025 -0500
@@ -140,8 +140,8 @@
         packsuffixlen = len(self.PACKSUFFIX)
 
         ids = set()
-        sizes = collections.defaultdict(lambda: 0)
-        mtimes = collections.defaultdict(lambda: [])
+        sizes = collections.defaultdict(int)
+        mtimes = collections.defaultdict(list)
         try:
             for filename, type, stat in osutil.listdir(self.path, stat=True):
                 id = None
--- a/hgext/remotefilelog/shallowutil.py	Mon Jan 06 01:06:59 2025 -0500
+++ b/hgext/remotefilelog/shallowutil.py	Mon Jan 06 01:12:54 2025 -0500
@@ -100,7 +100,7 @@
 
     e.g. [{'a': 4', 'b': 2}, {'b': 3, 'c': 1}] -> {'a': 4, 'b': 5, 'c': 1}
     """
-    result = collections.defaultdict(lambda: 0)
+    result = collections.defaultdict(int)
     for dict in dicts:
         for k, v in dict.items():
             result[k] += v
--- a/mercurial/revlogutils/debug.py	Mon Jan 06 01:06:59 2025 -0500
+++ b/mercurial/revlogutils/debug.py	Mon Jan 06 01:12:54 2025 -0500
@@ -305,9 +305,9 @@
     # intermediate snapshot against a prior snapshot
     numsemi = 0
     # snapshot count per depth
-    numsnapdepth = collections.defaultdict(lambda: 0)
+    numsnapdepth = collections.defaultdict(int)
     # number of snapshots with a non-ancestor delta
-    numsnapdepth_nad = collections.defaultdict(lambda: 0)
+    numsnapdepth_nad = collections.defaultdict(int)
     # delta against previous revision
     numprev = 0
     # delta against prev, where prev is a non-ancestor
--- a/tests/test-pathencode.py	Mon Jan 06 01:06:59 2025 -0500
+++ b/tests/test-pathencode.py	Mon Jan 06 01:12:54 2025 -0500
@@ -51,7 +51,7 @@
     """Construct and print a table of probabilities for path name
     components.  The numbers are percentages."""
 
-    counts = collections.defaultdict(lambda: 0)
+    counts = collections.defaultdict(int)
     for line in os.popen(cmd).read().splitlines():
         if line[-2:] in ('.i', '.d'):
             line = line[:-2]