[PATCH 09 of 10] mq: don't use mutable default argument value

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Dec 27 05:05:30 EST 2016



On 12/27/2016 01:03 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1482796795 25200
> #      Mon Dec 26 16:59:55 2016 -0700
> # Node ID c5b821235171ec0674de1b005f60ab3591c3ed2c
> # Parent  f58ff64d5360ec1d82e3abb8ce8fdae8b3be3e9b
> mq: don't use mutable default argument value
>
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -718,9 +718,10 @@ class queue(object):
>                  else:
>                      util.rename(absf, absorig)
>
>      def printdiff(self, repo, diffopts, node1, node2=None, files=None,
> -                  fp=None, changes=None, opts={}):
> +                  fp=None, changes=None, opts=None):
> +        opts = opts or {}

Same feedback about testing for None or using ().

>          stat = opts.get('stat')
>          m = scmutil.match(repo[node1], files, opts)
>          cmdutil.diffordiffstat(self.ui, repo, diffopts, node1, node2,  m,
>                                 changes, stat, fp)
> diff --git a/tests/test-check-code.t b/tests/test-check-code.t
> --- a/tests/test-check-code.t
> +++ b/tests/test-check-code.t
> @@ -29,11 +29,8 @@ New errors are not allowed. Warnings are
>     mutable default argument value (list)
>    hgext/convert/common.py:58:
>     >                  extra=None, sortkey=None, saverev=True, phase=phases.draft,
>     attribute default argument value may be mutable
> -  hgext/mq.py:722:
> -   >                   fp=None, changes=None, opts={}):
> -   mutable default argument value (dict)
>    hgext/rebase.py:686:
>     > def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=[],
>     mutable default argument value (list)
>    Skipping i18n/polib.py it has no-che?k-code (glob)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list