[prev in list] [next in list] [prev in thread] [next in thread]
List: mercurial-devel
Subject: Re: [PATCH 07 of 10] match: don't use mutable default argument value
From: Pierre-Yves David <pierre-yves.david () ens-lyon ! org>
Date: 2016-12-27 10:04:55
Message-ID: 03662e9d-5fe3-fcb3-7bcb-153dccf7ef77 () ens-lyon ! org
[Download RAW message or body]
On 12/27/2016 01:03 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1482796689 25200
> # Mon Dec 26 16:58:09 2016 -0700
> # Node ID 95a432e534c28e14ff776cba0de355f5f6cb42dd
> # Parent cdb830b22b187debced54bd0d6e11e932bd7fdad
> match: don't use mutable default argument value
>
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -84,9 +84,9 @@ def _kindpatsalwaysmatch(kindpats):
> return False
> return True
>
> class match(object):
> - def __init__(self, root, cwd, patterns, include=[], exclude=[],
> + def __init__(self, root, cwd, patterns, include=None, exclude=None,
> default='glob', exact=False, auditor=None, ctx=None,
> listsubrepos=False, warn=None, badfn=None):
> """build an object to match a set of file patterns
>
> @@ -113,8 +113,10 @@ class match(object):
> 'subinclude:<path>' - a file of patterns to match against files under
> the same directory
> '<something>' - a pattern of the specified default type
> """
> + include = include or []
> + exclude = exclude or []
Same feedback about testing for None or using ().
>
> self._root = root
> self._cwd = cwd
> self._files = [] # exact files and roots of patterns
> 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
> @@ -59,12 +59,8 @@ New errors are not allowed. Warnings are
> > def _localphasemove(pushop, nodes, phase=phases.public):
> attribute default argument value may be mutable
> 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=[],
> - mutable default argument value (list)
> - mutable default argument value (list)
> mercurial/policy.py:45:
> > policy = os.environ.get('HGMODULEPOLICY', policy)
> use encoding.environ instead (py3)
> Skipping mercurial/statprof.py it has no-che?k-code (glob)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
--
Pierre-Yves David
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic