Patchwork [1,of,3,STABLE] formatting: run black version 19.10b0 on the codebase

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 29, 2019, 11:08 a.m.
Message ID <86e3e803a4e6cac0b503.1572347336@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/42611/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 29, 2019, 11:08 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1572342090 -3600
#      Tue Oct 29 10:41:30 2019 +0100
# Branch stable
# Node ID 86e3e803a4e6cac0b503afd63bad3f4f43ff7e5a
# Parent  4565a0afc2891f0bbba8ea9d9df21267d18cf832
# EXP-Topic switch-to-black
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 86e3e803a4e6
formatting: run black version 19.10b0 on the codebase

The latest version of black is out and contains the change we needed. So we can
start using it now.

note: `test-check-format.t` will complains about this changes because it still
use `grey` and need to be migrated to `black`. See next changesets for this.
Augie Fackler - Oct. 30, 2019, 8:16 p.m.
On Tue, Oct 29, 2019 at 12:08:58PM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1572343645 -3600
> #      Tue Oct 29 11:07:25 2019 +0100
> # Branch stable
> # Node ID 17c367aaedbc1f72e6d5b19fb1de8828a1dca3ab
> # Parent  0e9acc6539a0d23b2a7428ad86cc4fa79e47d7a5
> # EXP-Topic switch-to-black
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 17c367aaedbc
> formatting: drop `grey`, our custom black version

queued, thanks

I'll send some follow-ups to try and prevent some footguns, I think.

Patch

diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -76,10 +76,9 @@  class gpg(object):
             fp = os.fdopen(fd, r'wb')
             fp.write(data)
             fp.close()
-            gpgcmd = b"%s --logger-fd 1 --status-fd 1 --verify \"%s\" \"%s\"" % (
-                self.path,
-                sigfile,
-                datafile,
+            gpgcmd = (
+                b"%s --logger-fd 1 --status-fd 1 --verify \"%s\" \"%s\""
+                % (self.path, sigfile, datafile,)
             )
             ret = procutil.filter(b"", gpgcmd)
         finally:
diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -212,11 +212,9 @@  class config(object):
     def read(self, path, fp=None, sections=None, remap=None):
         if not fp:
             fp = util.posixfile(path, b'rb')
-        assert (
-            getattr(fp, 'mode', r'rb') == r'rb'
-        ), b'config files must be opened in binary mode, got fp=%r mode=%r' % (
-            fp,
-            fp.mode,
+        assert getattr(fp, 'mode', r'rb') == r'rb', (
+            b'config files must be opened in binary mode, got fp=%r mode=%r'
+            % (fp, fp.mode,)
         )
         self.parse(
             path, fp.read(), sections=sections, remap=remap, include=self.read
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1187,10 +1187,9 @@  class filectx(basefilectx):
 
         assert (
             changeid is not None or fileid is not None or changectx is not None
-        ), b"bad args: changeid=%r, fileid=%r, changectx=%r" % (
-            changeid,
-            fileid,
-            changectx,
+        ), (
+            b"bad args: changeid=%r, fileid=%r, changectx=%r"
+            % (changeid, fileid, changectx,)
         )
 
         if filelog is not None:
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -867,12 +867,15 @@  class treemanifest(object):
         return not self._dirs or all(m._isempty() for m in self._dirs.values())
 
     def __repr__(self):
-        return b'<treemanifest dir=%s, node=%s, loaded=%s, dirty=%s at 0x%x>' % (
-            self._dir,
-            hex(self._node),
-            bool(self._loadfunc is _noop),
-            self._dirty,
-            id(self),
+        return (
+            b'<treemanifest dir=%s, node=%s, loaded=%s, dirty=%s at 0x%x>'
+            % (
+                self._dir,
+                hex(self._node),
+                bool(self._loadfunc is _noop),
+                self._dirty,
+                id(self),
+            )
         )
 
     def dir(self):
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -3116,9 +3116,7 @@  class TestRunner(object):
         vlog("# Using HGTMP", _strpath(self._hgtmp))
         vlog("# Using PATH", os.environ["PATH"])
         vlog(
-            "# Using",
-            _strpath(IMPL_PATH),
-            _strpath(osenvironb[IMPL_PATH]),
+            "# Using", _strpath(IMPL_PATH), _strpath(osenvironb[IMPL_PATH]),
         )
         vlog("# Writing to directory", _strpath(self._outputdir))