summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura M?dioni <laura.medioni@logilab.fr>2015-11-24 11:38:10 +0100
committerLaura M?dioni <laura.medioni@logilab.fr>2015-11-24 11:38:10 +0100
commit07253b750913858e119b8a31e055ddad4c3942f3 (patch)
treeb4dbc6120378b4d4045acc9bedaea999b2190454
parent7657744488044b5ed817ed0e3c28314462609266 (diff)
downloadpylint-07253b750913858e119b8a31e055ddad4c3942f3.tar.gz
Add some more comments about the limitations of this rule
related to issue #674
-rw-r--r--pylint/checkers/base.py7
-rw-r--r--pylint/test/functional/redefined_variable_type.py6
2 files changed, 10 insertions, 3 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 74e26ac..224c8d6 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1886,6 +1886,13 @@ class MultipleTypesChecker(BaseChecker):
"""Checks for variable type redefinitions (NoneType excepted)
At a function, method, class or module scope
+
+ This rule could be improved:
+ - Currently, if an attribute is set to different types in 2 methods of a
+ same class, it won't be detected (see functional test)
+ - One could improve the support for inference on assignment with tuples,
+ ifexpr, etc. Also it would be great to have support for inference on
+ str.split()
"""
__implements__ = IAstroidChecker
diff --git a/pylint/test/functional/redefined_variable_type.py b/pylint/test/functional/redefined_variable_type.py
index d88a9e9..1c41a9d 100644
--- a/pylint/test/functional/redefined_variable_type.py
+++ b/pylint/test/functional/redefined_variable_type.py
@@ -17,8 +17,8 @@ class MyClass(object):
self.var1 = 2. # [redefined-variable-type]
self.a_str = "hello"
a_str = False
- (a_str, b_str) = (1, 2)
- a_str = 2.0 if self.var else 1.0
+ (a_str, b_str) = (1, 2) # no support for inference on tuple assignment
+ a_str = 2.0 if self.var else 1.0 # no support for inference on ifexpr
def _getter(self):
return self.a_str
@@ -31,7 +31,7 @@ class MyClass(object):
var = 1
test = 'bar'
var = 'baz' # [redefined-variable-type]
- self.var = 1
+ self.var = 1 # the rule checks for redefinitions in the scope of a function or method
test = 'foo'
myint = 2
myint = False # [redefined-variable-type]