changeset 52663:dc36535a5edc

style: drop extraneous parentheses These were rewritten by `pyupgrade`.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 06 Jan 2025 14:07:43 -0500
parents 3b6f25190157
children 9db77d46de79
files contrib/benchmarks/__init__.py hgext/histedit.py hgext/mq.py hgext/rebase.py hgext/remotefilelog/remotefilelog.py hgext/remotefilelog/remotefilelogserver.py mercurial/admin/verify.py mercurial/branchmap.py mercurial/hgweb/webcommands.py mercurial/minirst.py mercurial/statprof.py mercurial/wireprotov1peer.py tests/test-ancestor.py tests/test-ui-verbosity.py tests/test-walkrepo.py
diffstat 15 files changed, 39 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/benchmarks/__init__.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/contrib/benchmarks/__init__.py	Mon Jan 06 14:07:43 2025 -0500
@@ -54,10 +54,8 @@
 if not reposnames:
     raise ValueError("No repositories found in $REPO_DIR")
 outputre = re.compile(
-    (
-        r'! wall (\d+.\d+) comb \d+.\d+ user \d+.\d+ sys '
-        r'\d+.\d+ \(best of \d+\)'
-    )
+    r'! wall (\d+.\d+) comb \d+.\d+ user \d+.\d+ sys '
+    r'\d+.\d+ \(best of \d+\)'
 )
 
 
--- a/hgext/histedit.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/hgext/histedit.py	Mon Jan 06 14:07:43 2025 -0500
@@ -1484,7 +1484,7 @@
             self.selected = oldpos if self.selected is None else None
             self.make_selection(self.selected)
         elif action == b'goto' and int(ch) < len(self.rules) <= 10:
-            newrule = next((r for r in self.rules if r.origpos == int(ch)))
+            newrule = next(r for r in self.rules if r.origpos == int(ch))
             self.move_cursor(oldpos, newrule.pos)
             if self.selected is not None:
                 self.swap(oldpos, newrule.pos)
--- a/hgext/mq.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/hgext/mq.py	Mon Jan 06 14:07:43 2025 -0500
@@ -1257,7 +1257,7 @@
             mar = changes[:3]
         else:
             mar = (changes.modified, changes.added, changes.removed)
-        if any((b'.hgsubstate' in files for files in mar)):
+        if any(b'.hgsubstate' in files for files in mar):
             return  # already listed up
         # not yet listed up
         if substatestate.added or not substatestate.any_tracked:
--- a/hgext/rebase.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/hgext/rebase.py	Mon Jan 06 14:07:43 2025 -0500
@@ -1825,11 +1825,9 @@
             # we have a more advanced merge algorithm that handles multiple bases.
             if l > 0:
                 unwanteddesc = _(b' or ').join(
-                    (
-                        b', '.join(b'%d:%s' % (r, repo[r]) for r in revs)
-                        for revs in unwanted
-                        if revs is not None
-                    )
+                    b', '.join(b'%d:%s' % (r, repo[r]) for r in revs)
+                    for revs in unwanted
+                    if revs is not None
                 )
                 raise error.InputError(
                     _(b'rebasing %d:%s will include unwanted changes from %s')
@@ -2043,7 +2041,7 @@
     for rev in sorted(state):
         parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev]
         # if all parents of this revision are done, then so is this revision
-        if parents and all((state.get(p) == p for p in parents)):
+        if parents and all(state.get(p) == p for p in parents):
             state[rev] = rev
     return originalwd, destmap, state
 
--- a/hgext/remotefilelog/remotefilelog.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/hgext/remotefilelog/remotefilelog.py	Mon Jan 06 14:07:43 2025 -0500
@@ -448,7 +448,7 @@
         parentrevs = collections.defaultdict(list)
         revmap = {}
         queue = collections.deque(
-            ((None, n) for n in parentsmap if n not in allparents)
+            (None, n) for n in parentsmap if n not in allparents
         )
         while queue:
             prevrev, current = queue.pop()
--- a/hgext/remotefilelog/remotefilelogserver.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/hgext/remotefilelog/remotefilelogserver.py	Mon Jan 06 14:07:43 2025 -0500
@@ -290,7 +290,7 @@
     """A server api for requesting a filelog's heads"""
     flog = repo.file(path)
     heads = flog.heads()
-    return b'\n'.join((hex(head) for head in heads if head != repo.nullid))
+    return b'\n'.join(hex(head) for head in heads if head != repo.nullid)
 
 
 def getfile(repo, proto, file, node):
--- a/mercurial/admin/verify.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/mercurial/admin/verify.py	Mon Jan 06 14:07:43 2025 -0500
@@ -224,7 +224,7 @@
 
             try:
                 matching_option = next(
-                    (o for o in check.func.options if o[0] == option_name)
+                    o for o in check.func.options if o[0] == option_name
                 )
             except StopIteration:
                 raise error.InputError(
--- a/mercurial/branchmap.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/mercurial/branchmap.py	Mon Jan 06 14:07:43 2025 -0500
@@ -145,7 +145,7 @@
                     closed.add(h)
 
         if rbheads:
-            rtiprev = max((int(clrev(node)) for node in rbheads))
+            rtiprev = max(int(clrev(node)) for node in rbheads)
             cache = new_branch_cache(
                 repo,
                 remotebranchmap,
--- a/mercurial/hgweb/webcommands.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/mercurial/hgweb/webcommands.py	Mon Jan 06 14:07:43 2025 -0500
@@ -1258,7 +1258,7 @@
         msg = b'Unsupported archive type: %s' % stringutil.pprint(type_)
         raise ErrorResponse(HTTP_NOT_FOUND, msg)
 
-    if not ((type_ in allowed or web.configbool(b"web", b"allow" + type_))):
+    if not (type_ in allowed or web.configbool(b"web", b"allow" + type_)):
         msg = b'Archive type not allowed: %s' % type_
         raise ErrorResponse(HTTP_FORBIDDEN, msg)
 
--- a/mercurial/minirst.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/mercurial/minirst.py	Mon Jan 06 14:07:43 2025 -0500
@@ -511,7 +511,7 @@
     colwidth = encoding.colwidth(block[b'optstr'])
     usablewidth = width - 1
     hanging = block[b'optstrwidth']
-    initindent = b'%s%s  ' % (block[b'optstr'], b' ' * ((hanging - colwidth)))
+    initindent = b'%s%s  ' % (block[b'optstr'], b' ' * (hanging - colwidth))
     hangindent = b' ' * (encoding.colwidth(initindent) + 1)
     return b' %s\n' % (
         stringutil.wrap(
--- a/mercurial/statprof.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/mercurial/statprof.py	Mon Jan 06 14:07:43 2025 -0500
@@ -959,16 +959,14 @@
     for sample in data.samples:
         stack = tuple(
             (
-                (
-                    '%s:%d'
-                    % (
-                        simplifypath(pycompat.sysstr(frame.path)),
-                        frame.lineno or -1,
-                    ),
-                    pycompat.sysstr(frame.function),
-                )
-                for frame in sample.stack
+                '%s:%d'
+                % (
+                    simplifypath(pycompat.sysstr(frame.path)),
+                    frame.lineno or -1,
+                ),
+                pycompat.sysstr(frame.function),
             )
+            for frame in sample.stack
         )
         qstack = collections.deque(stack)
         if laststack == qstack:
--- a/mercurial/wireprotov1peer.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/mercurial/wireprotov1peer.py	Mon Jan 06 14:07:43 2025 -0500
@@ -472,7 +472,7 @@
                 raise KeyError(b'unknown getbundle option type %s' % keytype)
             opts[key] = value
         f = self._callcompressable(b"getbundle", **pycompat.strkwargs(opts))
-        if any((cap.startswith(b'HG2') for cap in bundlecaps)):
+        if any(cap.startswith(b'HG2') for cap in bundlecaps):
             return bundle2.getunbundler(self.ui, f)
         else:
             return changegroupmod.cg1unpacker(f, b'UN')
--- a/tests/test-ancestor.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/tests/test-ancestor.py	Mon Jan 06 14:07:43 2025 -0500
@@ -352,10 +352,8 @@
 
 def genlazyancestors(revs, stoprev=0, inclusive=False):
     print(
-        (
-            "%% lazy ancestor set for %s, stoprev = %s, inclusive = %s"
-            % (revs, stoprev, inclusive)
-        )
+        "%% lazy ancestor set for %s, stoprev = %s, inclusive = %s"
+        % (revs, stoprev, inclusive)
     )
     return ancestor.lazyancestors(
         graph.get, revs, stoprev=stoprev, inclusive=inclusive
--- a/tests/test-ui-verbosity.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/tests/test-ui-verbosity.py	Mon Jan 06 14:07:43 2025 -0500
@@ -45,20 +45,18 @@
         check = ' +'
 
     print(
-        (
-            '%2d  %5s %5s %5s   %5s %5s %5s  ->  %5s %5s %5s%s'
-            % (
-                i,
-                hgrc_quiet,
-                hgrc_verbose,
-                hgrc_debug,
-                cmd_quiet,
-                cmd_verbose,
-                cmd_debug,
-                u.quiet,
-                u.verbose,
-                u.debugflag,
-                check,
-            )
+        '%2d  %5s %5s %5s   %5s %5s %5s  ->  %5s %5s %5s%s'
+        % (
+            i,
+            hgrc_quiet,
+            hgrc_verbose,
+            hgrc_debug,
+            cmd_quiet,
+            cmd_verbose,
+            cmd_debug,
+            u.quiet,
+            u.verbose,
+            u.debugflag,
+            check,
         )
     )
--- a/tests/test-walkrepo.py	Mon Jan 06 13:54:40 2025 -0500
+++ b/tests/test-walkrepo.py	Mon Jan 06 14:07:43 2025 -0500
@@ -35,18 +35,12 @@
     if sym and (len(reposet) != 3):
         print("reposet = %r" % (reposet,))
         print(
-            (
-                "Found %d repositories when I should have found 3"
-                % (len(reposet),)
-            )
+            "Found %d repositories when I should have found 3" % (len(reposet),)
         )
     if (not sym) and (len(reposet) != 2):
         print("reposet = %r" % (reposet,))
         print(
-            (
-                "Found %d repositories when I should have found 2"
-                % (len(reposet),)
-            )
+            "Found %d repositories when I should have found 2" % (len(reposet),)
         )
     sub1set = frozenset(
         (pjoin(b'.', b'sub1'), pjoin(b'.', b'circle', b'subdir', b'sub1'))