Patchwork [3,of,5] check-code: check for spaces around = for named parameters

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 3, 2013, 12:57 p.m.
Message ID <62dfe5a111163d9b724e.1380805021@mk-desktop>
Download mbox | patch
Permalink /patch/2720/
State Accepted
Commit 681f7b9213a45c89192f34e41b2ffddab98a367e
Headers show

Comments

Mads Kiilerich - Oct. 3, 2013, 12:57 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1380804647 -7200
#      Thu Oct 03 14:50:47 2013 +0200
# Node ID 62dfe5a111163d9b724e1f824bf63f5d40ae0902
# Parent  d66fc34a3b435d57492f65c8cb1f8065e4b7d6b3
check-code: check for spaces around = for named parameters

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -226,6 +226,8 @@ 
      "missing whitespace around operator"),
     (r'[^^+=*/!<>&| %-](\s=|=\s)[^= ]',
      "wrong whitespace around ="),
+    (r'\([^()]*( =[^=]|[^<>!=]= )',
+     "no whitespace around = for named parameters"),
     (r'raise Exception', "don't raise generic exceptions"),
     (r'raise [^,(]+, (\([^\)]+\)|[^,\(\)]+)$',
      "don't use old-style two-argument raise, use Exception(message)"),
diff --git a/contrib/hgfixes/fix_bytesmod.py b/contrib/hgfixes/fix_bytesmod.py
--- a/contrib/hgfixes/fix_bytesmod.py
+++ b/contrib/hgfixes/fix_bytesmod.py
@@ -58,6 +58,6 @@ 
         else:
             args = [formatstr, Comma().clone(), data]
 
-        call = Call(Name('bytesformatter', prefix = ' '), args)
+        call = Call(Name('bytesformatter', prefix=' '), args)
         return call
 
diff --git a/hgext/acl.py b/hgext/acl.py
--- a/hgext/acl.py
+++ b/hgext/acl.py
@@ -284,8 +284,8 @@ 
 
     cfg = ui.config('acl', 'config')
     if cfg:
-        ui.readconfig(cfg, sections = ['acl.groups', 'acl.allow.branches',
-        'acl.deny.branches', 'acl.allow', 'acl.deny'])
+        ui.readconfig(cfg, sections=['acl.groups', 'acl.allow.branches',
+            'acl.deny.branches', 'acl.allow', 'acl.deny'])
 
     allowbranches = buildmatch(ui, None, user, 'acl.allow.branches')
     denybranches = buildmatch(ui, None, user, 'acl.deny.branches')
diff --git a/hgext/highlight/__init__.py b/hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py
+++ b/hgext/highlight/__init__.py
@@ -50,7 +50,7 @@ 
 
 def generate_css(web, req, tmpl):
     pg_style = web.config('web', 'pygments_style', 'colorful')
-    fmter = highlight.HtmlFormatter(style = pg_style)
+    fmter = highlight.HtmlFormatter(style=pg_style)
     req.respond(common.HTTP_OK, 'text/css')
     return ['/* pygments_style = %s */\n\n' % pg_style,
             fmter.get_style_defs('')]
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1808,7 +1808,7 @@ 
     [('c', 'changelog', False, _('open changelog')),
      ('m', 'manifest', False, _('open manifest'))],
     _('-c|-m|FILE REV'))
-def debugdata(ui, repo, file_, rev = None, **opts):
+def debugdata(ui, repo, file_, rev=None, **opts):
     """dump the contents of a data file revision"""
     if opts.get('changelog') or opts.get('manifest'):
         file_, rev = None, file_
@@ -1919,7 +1919,7 @@ 
         ui.write("%s\n" % f)
 
 @command('debugfsinfo', [], _('[PATH]'))
-def debugfsinfo(ui, path = "."):
+def debugfsinfo(ui, path="."):
     """show information detected about current filesystem"""
     util.writefile('.debugfsinfo', '')
     ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
@@ -1974,7 +1974,7 @@ 
      ('m', 'manifest', False, _('open manifest')),
      ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
     _('[-f FORMAT] -c|-m|FILE'))
-def debugindex(ui, repo, file_ = None, **opts):
+def debugindex(ui, repo, file_=None, **opts):
     """dump the contents of an index file"""
     r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
     format = opts.get('format', 0)
@@ -2355,7 +2355,7 @@ 
      ('m', 'manifest', False, _('open manifest')),
      ('d', 'dump', False, _('dump index data'))],
      _('-c|-m|FILE'))
-def debugrevlog(ui, repo, file_ = None, **opts):
+def debugrevlog(ui, repo, file_=None, **opts):
     """show data and statistics about a revlog"""
     r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
 
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -338,7 +338,7 @@ 
                 morevars=morevars, lessvars=lessvars, query=query)
 
 def shortlog(web, req, tmpl):
-    return changelog(web, req, tmpl, shortlog = True)
+    return changelog(web, req, tmpl, shortlog=True)
 
 def changeset(web, req, tmpl):
     ctx = webutil.changectx(web.repo, req)
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -499,7 +499,7 @@ 
         data, self._rbuf = self._rbuf[:i], self._rbuf[i:]
         return data
 
-    def readlines(self, sizehint = 0):
+    def readlines(self, sizehint=0):
         total = 0
         list = []
         while True:
diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -140,7 +140,7 @@ 
 
 class exact(match):
     def __init__(self, root, cwd, files):
-        match.__init__(self, root, cwd, files, exact = True)
+        match.__init__(self, root, cwd, files, exact=True)
 
 class always(match):
     def __init__(self, root, cwd):
diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -101,7 +101,7 @@ 
 para_re = None
 space_re = None
 
-def fill(text, width, initindent = '', hangindent = ''):
+def fill(text, width, initindent='', hangindent=''):
     '''fill many paragraphs with optional indentation.'''
     global para_re, space_re
     if para_re is None:
diff --git a/tests/filterpyflakes.py b/tests/filterpyflakes.py
--- a/tests/filterpyflakes.py
+++ b/tests/filterpyflakes.py
@@ -46,6 +46,6 @@ 
         continue
     lines.append((msgtype, line))
 
-for msgtype, line in sorted(lines, key = makekey):
+for msgtype, line in sorted(lines, key=makekey):
     sys.stdout.write(line)
 print
diff --git a/tests/test-trusted.py b/tests/test-trusted.py
--- a/tests/test-trusted.py
+++ b/tests/test-trusted.py
@@ -145,7 +145,7 @@ 
 f.write('[foobar]\n')
 f.write('baz = quux\n')
 f.close()
-u.readconfig(filename, sections = ['foobar'])
+u.readconfig(filename, sections=['foobar'])
 print u.config('foobar', 'baz')
 
 print