Page MenuHomePhabricator

formatting: blacken the codebase
ClosedPublic

Authored by durin42 on Oct 5 2019, 10:05 AM.

Details

Summary

This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.

Done with:

hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S

skip-blame mass-reformatting only

  1. no-check-commit reformats foo_bar functions

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durin42 created this revision.Oct 5 2019, 10:05 AM
indygreg requested changes to this revision.Oct 5 2019, 10:29 AM
indygreg added inline comments.
hgext/fsmonitor/pywatchman/__init__.py
1 ↗(On Diff #16818)

This is 3rd party code and shouldn't be formatted.

This revision now requires changes to proceed.Oct 5 2019, 10:29 AM

Please also add # skip-blame to the commit message.

durin42 planned changes to this revision.Oct 5 2019, 11:03 AM

This still causes check-code problems, but it's getting close.

durin42 edited the summary of this revision. (Show Details)Oct 5 2019, 11:46 AM
durin42 updated this revision to Diff 16831.

Current test failures:

--- /usr/local/google/home/augie/hgtest/tests/test-check-code.t
+++ /usr/local/google/home/augie/hgtest/tests/test-check-code.t.err
@@ -27,9 +27,40 @@
   Skipping contrib/packaging/hgpackaging/wix.py it has no-che?k-code (glob)
   Skipping contrib/packaging/inno/build.py it has no-che?k-code (glob)
   Skipping contrib/packaging/wix/build.py it has no-che?k-code (glob)
+  doc/check-seclevel.py:50:
+   >     ui.note('checking "%s"\n' % name)
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:73:
+   >             ui.warn('gap of section level at "%s" of %s\n' % (title, name))
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:77:
+   >         ui.note(
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:91:
+   >             ui.note('skip checking %s: no help document\n' % (namefmt % name))
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:116:
+   >             ui.note('skip checking %s extension: no help document\n' % name)
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:141:
+   >     ui.note(
+   missing _() in ui message (use () to hide false-positives)
+  hgext/convert/cvsps.py:155:
+   >                 open(os.path.join(b'CVS', b'Repository'), b'rb').read().strip()
+   always assign an opened file to a variable, and close it afterwards
   Skipping i18n/polib.py it has no-che?k-code (glob)
+  mercurial/encoding.py:71:
+   >         (k.encode(r'utf-8'), v.encode(r'utf-8')) for k, v in os.environ.items()
+   use encoding.environ instead (py3)
+  mercurial/encoding.py:251:
+   >         for k, v in os.environ.items()
+   use encoding.environ instead (py3)
+  mercurial/pycompat.py:204:
+   >             if not isinstance(s, (bytes, bytearray)) and not hasattr(
+   hasattr(foo, bar) is broken on py2, use util.safehasattr(foo, bar) instead
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
   Skipping tests/badserverext.py it has no-che?k-code (glob)
+  [1]

 @commands in debugcommands.py should be in alphabetical order.
durin42 updated this revision to Diff 16842.Oct 5 2019, 1:45 PM

Now down to these failures:

+  doc/check-seclevel.py:50:
+   >     ui.note('checking "%s"\n' % name)
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:73:
+   >             ui.warn('gap of section level at "%s" of %s\n' % (title, name))
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:77:
+   >         ui.note(
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:91:
+   >             ui.note('skip checking %s: no help document\n' % (namefmt % name))
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:116:
+   >             ui.note('skip checking %s extension: no help document\n' % name)
+   missing _() in ui message (use () to hide false-positives)
+  doc/check-seclevel.py:141:
+   >     ui.note(
+   missing _() in ui message (use () to hide false-positives)
   Skipping i18n/polib.py it has no-che?k-code (glob)
+  mercurial/encoding.py:71:
+   >         (k.encode(r'utf-8'), v.encode(r'utf-8')) for k, v in os.environ.items()
+   use encoding.environ instead (py3)
+  mercurial/encoding.py:251:
+   >         for k, v in os.environ.items()
+   use encoding.environ instead (py3)
+  mercurial/pycompat.py:204:
+   >             if not isinstance(s, (bytes, bytearray)) and not hasattr(
+   hasattr(foo, bar) is broken on py2, use util.safehasattr(foo, bar) instead
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
   Skipping tests/badserverext.py it has no-che?k-code (glob)
+  [1]

a couple of these are comments that shifted around (sigh) and are easy. The missing _() are all in one file, so probably just define a no-op __() function to trick the checker?

durin42 added inline comments.Oct 5 2019, 2:06 PM
hgext/fsmonitor/pywatchman/__init__.py
1 ↗(On Diff #16818)

I'm not sold, honestly: we've already substantially diverged from upstream on this, so I think we should just act like we own it for now.

durin42 updated this revision to Diff 16844.Oct 5 2019, 2:08 PM
indygreg added inline comments.Oct 5 2019, 3:03 PM
hgext/fsmonitor/pywatchman/__init__.py
1 ↗(On Diff #16818)

We need to take some upstream Python 3 changes soon. Can we defer this directory until we do that in case there are merge conflict issues?

durin42 updated this revision to Diff 16868.Oct 6 2019, 9:51 AM
durin42 updated this revision to Diff 16882.Oct 6 2019, 10:56 AM
durin42 updated this revision to Diff 16899.Oct 6 2019, 12:00 PM
indygreg accepted this revision.Oct 6 2019, 12:02 PM
This revision is now accepted and ready to land.Oct 6 2019, 12:02 PM
This revision was automatically updated to reflect the committed changes.