diff options
author | Torsten Marek <shlomme@gmail.com> | 2014-07-24 15:07:51 +0200 |
---|---|---|
committer | Torsten Marek <shlomme@gmail.com> | 2014-07-24 15:07:51 +0200 |
commit | 7aa57622583caab7dc14d0458bc3c4082036b766 (patch) | |
tree | 8235d02ff30784eb6656abedba5daa71fbd8fd22 /checkers/variables.py | |
parent | a7d1515daef1234b3bf3e3991299771bea3c56bc (diff) | |
download | pylint-7aa57622583caab7dc14d0458bc3c4082036b766.tar.gz |
Implement confidence levels.
- attach confidence levels to a number of messages
- include confidence levels in the message object
- if the confidence of a message is not HIGH or UNDEFINED,
include it in the test output.
Diffstat (limited to 'checkers/variables.py')
-rw-r--r-- | checkers/variables.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/checkers/variables.py b/checkers/variables.py index a88bf3b..9c0b15c 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -25,14 +25,14 @@ from astroid import are_exclusive, builtin_lookup, AstroidBuildingException from logilab.common.modutils import file_from_modpath -from pylint.interfaces import IAstroidChecker +from pylint.interfaces import IAstroidChecker, INFERENCE, INFERENCE_FAILURE, HIGH from pylint.utils import get_global_option from pylint.checkers import BaseChecker from pylint.checkers.utils import ( PYMETHODS, is_ancestor_name, is_builtin, is_defined_before, is_error, is_func_default, is_func_decorator, assign_parent, check_messages, is_inside_except, clobber_in_except, - get_all_elements) + get_all_elements, has_known_bases) SPECIAL_OBJ = re.compile("^_{2}[a-z]+_{2}$") @@ -486,6 +486,10 @@ builtins. Remember that you should avoid to define new builtins when possible.' klass = node.parent.frame() if is_method and (klass.type == 'interface' or node.is_abstract()): return + if is_method and isinstance(klass, astroid.Class): + confidence = INFERENCE if has_known_bases(klass) else INFERENCE_FAILURE + else: + confidence = HIGH authorized_rgx = self.config.dummy_variables_rgx called_overridden = False argnames = node.argnames() @@ -539,7 +543,8 @@ builtins. Remember that you should avoid to define new builtins when possible.' # don't check callback arguments XXX should be configurable if node.name.startswith('cb_') or node.name.endswith('_cb'): continue - self.add_message('unused-argument', args=name, node=stmt) + self.add_message('unused-argument', args=name, node=stmt, + confidence=confidence) else: if stmt.parent and isinstance(stmt.parent, astroid.Assign): if name in nonlocal_names: |