From 07253b750913858e119b8a31e055ddad4c3942f3 Mon Sep 17 00:00:00 2001 From: Laura M?dioni Date: Tue, 24 Nov 2015 11:38:10 +0100 Subject: Add some more comments about the limitations of this rule related to issue #674 --- pylint/checkers/base.py | 7 +++++++ pylint/test/functional/redefined_variable_type.py | 6 +++--- 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] -- cgit v1.2.1