Patchwork [4,of,4] ui: avoid mutable default arguments

login
register
mail settings
Submitter Matt Mackall
Date Sept. 23, 2015, 4:16 p.m.
Message ID <1443025008.10817.152.camel@selenic.com>
Download mbox | patch
Permalink /patch/10594/
State Accepted
Headers show

Comments

Matt Mackall - Sept. 23, 2015, 4:16 p.m.
On Wed, 2015-09-23 at 02:05 -0700, Pierre-Yves David wrote:
> 
> On 09/22/2015 05:15 PM, Siddharth Agarwal wrote:
> > # HG changeset patch
> > # User Siddharth Agarwal <sid0@fb.com>
> > # Date 1442966194 25200
> > #      Tue Sep 22 16:56:34 2015 -0700
> > # Node ID 75950e78a828c5994bd36974bdfbc5f62a0009a3
> > # Parent  2e9d6b73a2a88c044175a05d32626b18afc0e889
> > ui: avoid mutable default arguments
> 
> eeeeeeeerk, patches 3 and 4 pushed to the clowncopter.

We've got a bunch more {} and [].

$ hg diff


$ hg check
hgext/histedit.py:645 (pierre-yves@19021):
 > def findoutgoing(ui, repo, remote=None, force=False, opts={}):
 don't use mutable default arguments
hgext/largefiles/overrides.py:53 (natosha@16247):
 >     def overridematch(ctx, pats=[], opts={}, globbed=False,
 don't use mutable default arguments
hgext/largefiles/overrides.py:290 (lmoscovicz@21466):
 >     def overridematchandpats(ctx, pats=[], opts={}, globbed=False,
 don't use mutable default arguments
hgext/largefiles/overrides.py:616 (mpm@28415):
 >         def overridematch(ctx, pats=[], opts={}, globbed=False,
 don't use mutable default arguments
hgext/largefiles/overrides.py:725 (martinvonz@27257):
 >         def overridematch(mctx, pats=[], opts={}, globbed=False,
 don't use mutable default arguments
hgext/largefiles/overrides.py:1167 (matt_harbison@25726):
 > def scmutiladdremove(orig, repo, matcher, prefix, opts={}, dry_run=None,
 don't use mutable default arguments
hgext/mq.py:486 (pmezard@10184):
 >     def diffopts(self, opts={}, patchfn=None):
 don't use mutable default arguments
hgext/transplant.py:120 (brendan@3714):
 >     def apply(self, repo, source, revmap, merges, opts={}):
 don't use mutable default arguments
Skipping hgext/zeroconf/Zeroconf.py it has no-check-code
Skipping i18n/polib.py it has no-check-code
mercurial/cmdutil.py:2766 (kbullock@18688):
 > def commitstatus(repo, node, branch, bheads=None, opts={}):
 don't use mutable default arguments
Skipping mercurial/httpclient/__init__.py it has no-check-code
Skipping mercurial/httpclient/_readers.py it has no-check-code
Skipping mercurial/httpclient/socketutil.py it has no-check-code
mercurial/httpconnection.py:110 (durin42@14244):
 >     def request(self, method, uri, body=None, headers={}):
 don't use mutable default arguments
mercurial/localrepo.py:543 (foozy@21636):
 >     def _tag(self, names, node, message, local, user, date, extra={},
 don't use mutable default arguments
mercurial/scmutil.py:756 (matt_harbison@29074):
 > def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath',
 don't use mutable default arguments
mercurial/scmutil.py:779 (matt_harbison@29074):
 > def match(ctx, pats=[], opts={}, globbed=False, default='relpath', badfn=None):
 don't use mutable default arguments
mercurial/scmutil.py:791 (matt_harbison@25726):
 > def addremove(repo, matcher, prefix, opts={}, dry_run=None, similarity=None):
 don't use mutable default arguments
mercurial/templater.py:795 (dirkjan@8218):
 >     def __init__(self, loader, filters={}, defaults={}):
 don't use mutable default arguments
mercurial/templater.py:832 (brendan@7396):
 >     def __init__(self, mapfile, filters={}, defaults={}, cache={},
 don't use mutable default arguments
Pierre-Yves David - Sept. 24, 2015, 1:05 p.m.
On 09/23/2015 09:16 AM, Matt Mackall wrote:
> On Wed, 2015-09-23 at 02:05 -0700, Pierre-Yves David wrote:
>>
>> On 09/22/2015 05:15 PM, Siddharth Agarwal wrote:
>>> # HG changeset patch
>>> # User Siddharth Agarwal <sid0@fb.com>
>>> # Date 1442966194 25200
>>> #      Tue Sep 22 16:56:34 2015 -0700
>>> # Node ID 75950e78a828c5994bd36974bdfbc5f62a0009a3
>>> # Parent  2e9d6b73a2a88c044175a05d32626b18afc0e889
>>> ui: avoid mutable default arguments
>>
>> eeeeeeeerk, patches 3 and 4 pushed to the clowncopter.
>
> We've got a bunch more {} and [].

I've cleaned these up, this is an about 27 patches series that can be 
pulled here:

hg pull -r 266a98ba3e42 http://hg.netv6.net/marmoute-wip/mercurial/

hg summ--
Pierre-Yves David
Pierre-Yves David - Sept. 24, 2015, 5:09 p.m.
On 09/24/2015 08:51 AM, Kevin Bullock wrote:
>> On Sep 24, 2015, at 08:05, Pierre-Yves David
>> <pierre-yves.david@ens-lyon.org
>> <mailto:pierre-yves.david@ens-lyon.org>> wrote:
>>
>> On 09/23/2015 09:16 AM, Matt Mackall wrote:
>>> On Wed, 2015-09-23 at 02:05 -0700, Pierre-Yves David wrote:
>>>>
>>>> On 09/22/2015 05:15 PM, Siddharth Agarwal wrote:
>>>>> # HG changeset patch
>>>>> # User Siddharth Agarwal <sid0@fb.com <mailto:sid0@fb.com>>
>>>>> # Date 1442966194 25200
>>>>> #      Tue Sep 22 16:56:34 2015 -0700
>>>>> # Node ID 75950e78a828c5994bd36974bdfbc5f62a0009a3
>>>>> # Parent  2e9d6b73a2a88c044175a05d32626b18afc0e889
>>>>> ui: avoid mutable default arguments
>>>>
>>>> eeeeeeeerk, patches 3 and 4 pushed to the clowncopter.
>>>
>>> We've got a bunch more {} and [].
>>
>> I've cleaned these up, this is an about 27 patches series that can be
>> pulled here:
>>
>> hg pull -r 266a98ba3e42 http://hg.netv6.net/marmoute-wip/mercurial/
>
> Series LGTM.

Okay, that is now pushed to the clowcopter.

Patch

diff -r 60558319ce72 contrib/check-code.py
--- a/contrib/check-code.py	Tue Sep 22 16:56:34 2015 -0700
+++ b/contrib/check-code.py	Wed Sep 23 11:13:25 2015 -0500
@@ -291,6 +291,7 @@ 
     (r'os\.path\.join\(.*, *(""|\'\')\)',
      "use pathutil.normasprefix(path) instead of os.path.join(path, '')"),
     (r'\s0[0-7]+\b', 'legacy octal syntax; use "0o" prefix instead of "0"'),
+    (r'def.*[( ]\w+=\{\}', "don't use mutable default arguments"),
   ],
   # warnings
   [