diff options
author | Torsten Marek <tmarek@google.com> | 2013-03-29 17:45:04 +0100 |
---|---|---|
committer | Torsten Marek <tmarek@google.com> | 2013-03-29 17:45:04 +0100 |
commit | 7b0b774031f846b9da6eec179d7007eb2cc4149d (patch) | |
tree | 4a56de8276a2217fc85e9f5af22443bd7b7c13dd /checkers | |
parent | 5f675eceeac5879994a0e3a55ac1d3e6be0af00f (diff) | |
download | pylint-git-7b0b774031f846b9da6eec179d7007eb2cc4149d.tar.gz |
Unify handling for dangerous default values and make sure that set, dict and list literals
are treated the same way as list(), set() and dict().
Depends on inference fixes found in logilab-astng 0.24.3/0.25
Diffstat (limited to 'checkers')
-rw-r--r-- | checkers/base.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/checkers/base.py b/checkers/base.py index 41e4b931f..1fab58b34 100644 --- a/checkers/base.py +++ b/checkers/base.py @@ -448,18 +448,15 @@ functions, methods value = default.infer().next() except astng.InferenceError: continue - if isinstance(value, (astng.Dict, astng.List)): + if (isinstance(value, astng.Instance) and + value.qname() in ('__builtin__.set', '__builtin__.dict', '__builtin__.list')): if value is default: msg = default.as_string() + elif type(value) is astng.Instance: + msg = '%s (%s)' % (default.as_string(), value.qname()) else: msg = '%s (%s)' % (default.as_string(), value.as_string()) self.add_message('W0102', node=node, args=(msg,)) - if value.qname() == '__builtin__.set': - if isinstance(default, astng.CallFunc): - msg = default.as_string() - else: - msg = '%s (%s)' % (default.as_string(), value.qname()) - self.add_message('W0102', node=node, args=(msg,)) @check_messages('W0101', 'W0150') def visit_return(self, node): |