Mercurial > public > mercurial-scm > hg-stable
diff tests/check-perf-code.py @ 43076:2372284d9457
formatting: blacken the codebase
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
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | caebe5e7f4bd |
children | c102b704edb5 |
line wrap: on
line diff
--- a/tests/check-perf-code.py Sat Oct 05 10:29:34 2019 -0400 +++ b/tests/check-perf-code.py Sun Oct 06 09:45:02 2019 -0400 @@ -9,23 +9,31 @@ # write static check patterns here perfpypats = [ - [ - (r'(branchmap|repoview|repoviewutil)\.subsettable', - "use getbranchmapsubsettable() for early Mercurial"), - (r'\.(vfs|svfs|opener|sopener)', - "use getvfs()/getsvfs() for early Mercurial"), - (r'ui\.configint', - "use getint() instead of ui.configint() for early Mercurial"), - ], - # warnings - [ - ] + [ + ( + r'(branchmap|repoview|repoviewutil)\.subsettable', + "use getbranchmapsubsettable() for early Mercurial", + ), + ( + r'\.(vfs|svfs|opener|sopener)', + "use getvfs()/getsvfs() for early Mercurial", + ), + ( + r'ui\.configint', + "use getint() instead of ui.configint() for early Mercurial", + ), + ], + # warnings + [], ] + def modulewhitelist(names): - replacement = [('.py', ''), ('.c', ''), # trim suffix - ('mercurial%s' % ('/'), ''), # trim "mercurial/" path - ] + replacement = [ + ('.py', ''), + ('.c', ''), # trim suffix + ('mercurial%s' % '/', ''), # trim "mercurial/" path + ] ignored = {'__init__'} modules = {} @@ -45,6 +53,7 @@ return whitelist + if __name__ == "__main__": # in this case, it is assumed that result of "hg files" at # multiple revisions is given via stdin @@ -61,10 +70,14 @@ # bar, # baz # ) - ((r'from mercurial import [(][a-z0-9, \n#]*\n(?! *%s,|^[ #]*\n|[)])' - % ',| *'.join(whitelist)), - "import newer module separately in try clause for early Mercurial" - )) + ( + ( + r'from mercurial import [(][a-z0-9, \n#]*\n(?! *%s,|^[ #]*\n|[)])' + % ',| *'.join(whitelist) + ), + "import newer module separately in try clause for early Mercurial", + ) + ) # import contrib/check-code.py as checkcode assert 'RUNTESTDIR' in os.environ, "use check-perf-code.py in *.t script" @@ -73,7 +86,8 @@ checkcode = __import__('check-code') # register perf.py specific entry with "checks" in check-code.py - checkcode.checks.append(('perf.py', r'contrib/perf.py$', '', - checkcode.pyfilters, perfpypats)) + checkcode.checks.append( + ('perf.py', r'contrib/perf.py$', '', checkcode.pyfilters, perfpypats) + ) sys.exit(checkcode.main())