[PATCH 06 of 10] hgweb: don't use default mutable argument value

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



On 12/27/2016 01:03 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1482796613 25200
> #      Mon Dec 26 16:56:53 2016 -0700
> # Node ID cdb830b22b187debced54bd0d6e11e932bd7fdad
> # Parent  1b0f806daa5e47cd88f6c1364cff06d96c1809db
> hgweb: don't use default mutable argument value
>
> diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
> --- a/mercurial/hgweb/webutil.py
> +++ b/mercurial/hgweb/webutil.py
> @@ -141,9 +141,10 @@ class filerevnav(revnav):
>      def hex(self, rev):
>          return hex(self._changelog.node(self._revlog.linkrev(rev)))
>
>  class _siblings(object):
> -    def __init__(self, siblings=[], hiderev=None):
> +    def __init__(self, siblings=None, hiderev=None):
> +        siblings = siblings or []

Same feedback about testing for None or using ().

>          self.siblings = [s for s in siblings if s.node() != nullid]
>          if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
>              self.siblings = []
>
> 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
> @@ -57,11 +57,8 @@ New errors are not allowed. Warnings are
>     use encoding.environ instead (py3)
>    mercurial/exchange.py:1019:
>     > def _localphasemove(pushop, nodes, phase=phases.public):
>     attribute default argument value may be mutable
> -  mercurial/hgweb/webutil.py:145:
> -   >     def __init__(self, siblings=[], hiderev=None):
> -   mutable default argument value (list)
>    Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
>    Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
>    mercurial/match.py:88:
>     >     def __init__(self, root, cwd, patterns, include=[], exclude=[],
> _______________________________________________
> 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